From 049973b23a6c77186dae45f708cdc0aa52b3a09e Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 1 Oct 2014 12:03:00 +0100 Subject: [PATCH 0001/1375] iio: Add si7005 relative humidity and temperature sensor driver sensor provides 12-bit relative humidity and 14-bit temperature via I2C interface; temperature and linearity compensation is not implemented (yet) driver also supports the Si7015, but not the 2nd generation sensors Si7013/Si7020/Si7021 datasheet is here http://www.silabs.com/Support%20Documents/TechnicalDocs/Si7005.pdf v2: (thanks to Lars-Peter Clausen) * fix coding style * use devm_iio_device_register() * change copyright year to 2014 Signed-off-by: Peter Meerwald Reviewed-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/Kconfig | 10 ++ drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/si7005.c | 189 ++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 drivers/iio/humidity/si7005.c diff --git a/drivers/iio/humidity/Kconfig b/drivers/iio/humidity/Kconfig index 463c4d9da79e..e116bd8dd0e4 100644 --- a/drivers/iio/humidity/Kconfig +++ b/drivers/iio/humidity/Kconfig @@ -12,4 +12,14 @@ config DHT11 Other sensors should work as well as long as they speak the same protocol. +config SI7005 + tristate "SI7005 relative humidity and temperature sensor" + depends on I2C + help + Say yes here to build support for the Silabs Si7005 relative + humidity and temperature sensor. + + To compile this driver as a module, choose M here: the module + will be called si7005. + endmenu diff --git a/drivers/iio/humidity/Makefile b/drivers/iio/humidity/Makefile index d5d36c0c95f9..e3f3d942e646 100644 --- a/drivers/iio/humidity/Makefile +++ b/drivers/iio/humidity/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_DHT11) += dht11.o +obj-$(CONFIG_SI7005) += si7005.o diff --git a/drivers/iio/humidity/si7005.c b/drivers/iio/humidity/si7005.c new file mode 100644 index 000000000000..bdd586e6d955 --- /dev/null +++ b/drivers/iio/humidity/si7005.c @@ -0,0 +1,189 @@ +/* + * si7005.c - Support for Silabs Si7005 humidity and temperature sensor + * + * Copyright (c) 2014 Peter Meerwald + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * (7-bit I2C slave address 0x40) + * + * TODO: heater, fast mode, processed mode (temp. / linearity compensation) + */ + +#include +#include +#include +#include +#include + +#include +#include + +#define SI7005_STATUS 0x00 +#define SI7005_DATA 0x01 /* 16-bit, MSB */ +#define SI7005_CONFIG 0x03 +#define SI7005_ID 0x11 + +#define SI7005_STATUS_NRDY BIT(0) +#define SI7005_CONFIG_TEMP BIT(4) +#define SI7005_CONFIG_START BIT(0) + +#define SI7005_ID_7005 0x50 +#define SI7005_ID_7015 0xf0 + +struct si7005_data { + struct i2c_client *client; + struct mutex lock; + u8 config; +}; + +static int si7005_read_measurement(struct si7005_data *data, bool temp) +{ + int tries = 50; + int ret; + + mutex_lock(&data->lock); + + ret = i2c_smbus_write_byte_data(data->client, SI7005_CONFIG, + data->config | SI7005_CONFIG_START | + (temp ? SI7005_CONFIG_TEMP : 0)); + if (ret < 0) + goto done; + + while (tries-- > 0) { + msleep(20); + ret = i2c_smbus_read_byte_data(data->client, SI7005_STATUS); + if (ret < 0) + goto done; + if (!(ret & SI7005_STATUS_NRDY)) + break; + } + if (tries < 0) { + ret = -EIO; + goto done; + } + + ret = i2c_smbus_read_word_swapped(data->client, SI7005_DATA); + +done: + mutex_unlock(&data->lock); + + return ret; +} + +static int si7005_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct si7005_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = si7005_read_measurement(data, chan->type == IIO_TEMP); + if (ret < 0) + return ret; + *val = ret; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + if (chan->type == IIO_TEMP) { + *val = 7; + *val2 = 812500; + } else { + *val = 3; + *val2 = 906250; + } + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_OFFSET: + if (chan->type == IIO_TEMP) + *val = -50 * 32 * 4; + else + *val = -24 * 16 * 16; + return IIO_VAL_INT; + default: + break; + } + + return -EINVAL; +} + +static const struct iio_chan_spec si7005_channels[] = { + { + .type = IIO_HUMIDITYRELATIVE, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OFFSET), + }, + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OFFSET), + } +}; + +static const struct iio_info si7005_info = { + .read_raw = si7005_read_raw, + .driver_module = THIS_MODULE, +}; + +static int si7005_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct si7005_data *data; + int ret; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) + return -ENODEV; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + mutex_init(&data->lock); + + indio_dev->dev.parent = &client->dev; + indio_dev->name = dev_name(&client->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &si7005_info; + + indio_dev->channels = si7005_channels; + indio_dev->num_channels = ARRAY_SIZE(si7005_channels); + + ret = i2c_smbus_read_byte_data(client, SI7005_ID); + if (ret < 0) + return ret; + if (ret != SI7005_ID_7005 && ret != SI7005_ID_7015) + return -ENODEV; + + ret = i2c_smbus_read_byte_data(client, SI7005_CONFIG); + if (ret < 0) + return ret; + data->config = ret; + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id si7005_id[] = { + { "si7005", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, si7005_id); + +static struct i2c_driver si7005_driver = { + .driver = { + .name = "si7005", + .owner = THIS_MODULE, + }, + .probe = si7005_probe, + .id_table = si7005_id, +}; +module_i2c_driver(si7005_driver); + +MODULE_AUTHOR("Peter Meerwald "); +MODULE_DESCRIPTION("Silabs Si7005 humidity and temperature sensor driver"); +MODULE_LICENSE("GPL"); From 82b7afbc8a6d0f97677bb9b3bf9179eae3dc3637 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Wed, 1 Oct 2014 20:59:00 +0100 Subject: [PATCH 0002/1375] iio:adc:max1363 clear list of missing features Remove "Control of internal reference" from the list of unimplemented features, since as of commit a405b00, external reference is supported if the device has a regulator and falls back to internal if it doesn't. While we are modifying the header, let's make it more concise and remove a redundant filename. Signed-off-by: Vivien Didelot Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1363.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index e283f2f2ee2f..122827266796 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -8,17 +8,11 @@ * based on linux/drivers/acron/char/pcf8583.c * Copyright (C) 2000 Russell King * + * Driver for max1363 and similar chips. + * * 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. - * - * max1363.c - * - * Partial support for max1363 and similar chips. - * - * Not currently implemented. - * - * - Control of internal reference. */ #include From 4f38521b38e1b14621d9301198d2548873a64490 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Tue, 1 Jul 2014 22:29:00 +0100 Subject: [PATCH 0003/1375] iio: Remove obsolete variable in adjd_s311 driver len variable become obsolete with iio_push_to_buffers_with_timestamp() Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/adjd_s311.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index f3068477b466..1d8ecb787944 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -120,7 +120,6 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct adjd_s311_data *data = iio_priv(indio_dev); s64 time_ns = iio_get_time_ns(); - int len = 0; int i, j = 0; int ret = adjd_s311_req_data(indio_dev); @@ -135,7 +134,6 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p) goto done; data->buffer[j++] = ret & ADJD_S311_DATA_MASK; - len += 2; } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, time_ns); From 92a18a841bb0d561a937796eeb40981be94b9dc7 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Tue, 1 Jul 2014 22:29:00 +0100 Subject: [PATCH 0004/1375] iio: Remove obsolete variable in tcs3472 driver len variable became obsolete with iio_push_to_buffers_with_timestamp() Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/tcs3472.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index 887fecf1f9bb..fe063a0a21cd 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -179,7 +179,6 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct tcs3472_data *data = iio_priv(indio_dev); - int len = 0; int i, j = 0; int ret = tcs3472_req_data(data); @@ -194,7 +193,6 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p) goto done; data->buffer[j++] = ret; - len += 2; } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, From 36eb8cc2cedadee888deb9a657a10be159f2dc0b Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 1 Sep 2014 15:15:00 +0100 Subject: [PATCH 0005/1375] iio: delete non-required instances of include None of these files are actually using any __init type directives and hence don't need to include . Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 1 - drivers/iio/adc/twl6030-gpadc.c | 1 - drivers/iio/dac/max517.c | 1 - drivers/iio/dac/mcp4725.c | 1 - drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 1 - drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 1 - drivers/iio/light/adjd_s311.c | 1 - 7 files changed, 7 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index d4d748214e4b..30261a9bd3d4 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index 53e1c645cee7..c40ca3aac108 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -28,7 +28,6 @@ * 02110-1301 USA * */ -#include #include #include #include diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c index de76e6a34c1e..9a82a7255ebb 100644 --- a/drivers/iio/dac/max517.c +++ b/drivers/iio/dac/max517.c @@ -19,7 +19,6 @@ */ #include -#include #include #include #include diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 7d9f5c31d2fc..43d14588448d 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index df7f1e1157ae..bf7223b275ac 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -12,7 +12,6 @@ */ #include -#include #include #include #include diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 429517117eff..0cd306a72a6e 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -12,7 +12,6 @@ */ #include -#include #include #include #include diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index 1d8ecb787944..09ad5f1ce539 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -14,7 +14,6 @@ */ #include -#include #include #include #include From 4a2bbdb45e5538dcf3d9f3d9299dd7b9bc3c076f Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 1 Nov 2014 14:54:00 +0000 Subject: [PATCH 0006/1375] iio:pressure:mpl3115: Fix sparse cast to restricted __be32 warning >> >> drivers/iio/pressure/mpl3115.c:101:46: sparse: cast to restricted __be32 >> >> drivers/iio/pressure/mpl3115.c:115:46: sparse: cast to restricted __be32 Signed-off-by: Peter Meerwald Reported-by: kbuild test robot Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/mpl3115.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index ac8c8ab723e5..ba6d0c520e63 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -77,7 +77,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct mpl3115_data *data = iio_priv(indio_dev); - s32 tmp = 0; + __be32 tmp = 0; int ret; switch (mask) { From 1a5b7d41f8f6ec087372bef348c46f5844a472b6 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Tue, 17 Dec 2013 16:16:00 +0000 Subject: [PATCH 0007/1375] iio: at91: document ADC clock properties Document the clock properties required by the at91 ADC driver. Signed-off-by: Boris Brezillon Acked-by: Nicolas Ferre Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/arm/atmel-adc.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/atmel-adc.txt b/Documentation/devicetree/bindings/arm/atmel-adc.txt index d1061469f63d..9a1175b46f49 100644 --- a/Documentation/devicetree/bindings/arm/atmel-adc.txt +++ b/Documentation/devicetree/bindings/arm/atmel-adc.txt @@ -5,6 +5,9 @@ Required properties: can be "at91sam9260", "at91sam9g45" or "at91sam9x5" - reg: Should contain ADC registers location and length - interrupts: Should contain the IRQ line for the ADC + - clock-names: tuple listing input clock names. + Required elements: "adc_clk", "adc_op_clk". + - clocks: phandles to input clocks. - atmel,adc-channels-used: Bitmask of the channels muxed and enable for this device - atmel,adc-startup-time: Startup Time of the ADC in microseconds as @@ -44,6 +47,8 @@ adc0: adc@fffb0000 { compatible = "atmel,at91sam9260-adc"; reg = <0xfffb0000 0x100>; interrupts = <20 4>; + clocks = <&adc_clk>, <&adc_op_clk>; + clock-names = "adc_clk", "adc_op_clk"; atmel,adc-channel-base = <0x30>; atmel,adc-channels-used = <0xff>; atmel,adc-drdy-mask = <0x10000>; From 2690be9051236898fb3f5da6d86c1202ec3f1aed Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 1 Oct 2014 22:01:00 +0100 Subject: [PATCH 0008/1375] iio: Add Lite-On ltr501 ambient light / proximity sensor driver combined ambient light (two channels) and proximity sensor with I2C interface; the ALS channels are visible+IR and IR datasheet is here http://optoelectronics.liteon.com/upload/download/DS86-2012-0006/P_100_LTR-501ALS-01_PrelimDS_ver1.1.pdf v3: * fix use of sizeof in _read_als() v2: (thanks to Lars-Peter Clausen) * cannot use devm_iio_device_register() due to cleanup order in _remove() * mutex around data wait/read * turn info message in _probe() into check for part number * change copyright year to 2014 Signed-off-by: Peter Meerwald Reviewed-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/ltr501.c | 445 +++++++++++++++++++++++++++++++++++++ 3 files changed, 458 insertions(+) create mode 100644 drivers/iio/light/ltr501.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index d12b2a0dbfbc..3a7a5d9f03a3 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -90,6 +90,18 @@ config SENSORS_LM3533 changes. The ALS-control output values can be set per zone for the three current output channels. +config LTR501 + tristate "LTR-501ALS-01 light sensor" + depends on I2C + select IIO_BUFFER + 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. + + This driver can also be built as a module. If so, the module + will be called ltr501. + config TCS3472 tristate "TAOS TCS3472 color light-to-digital converter" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 60e35ac07ff0..924530597f83 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_CM36651) += cm36651.o obj-$(CONFIG_GP2AP020A00F) += gp2ap020a00f.o obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o +obj-$(CONFIG_LTR501) += ltr501.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o obj-$(CONFIG_TCS3472) += tcs3472.o obj-$(CONFIG_TSL4531) += tsl4531.o diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c new file mode 100644 index 000000000000..62b7072af4de --- /dev/null +++ b/drivers/iio/light/ltr501.c @@ -0,0 +1,445 @@ +/* + * ltr501.c - Support for Lite-On LTR501 ambient light and proximity sensor + * + * Copyright 2014 Peter Meerwald + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * 7-bit I2C slave address 0x23 + * + * TODO: interrupt, threshold, measurement rate, IR LED characteristics + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define LTR501_DRV_NAME "ltr501" + +#define LTR501_ALS_CONTR 0x80 /* ALS operation mode, SW reset */ +#define LTR501_PS_CONTR 0x81 /* PS operation mode */ +#define LTR501_PART_ID 0x86 +#define LTR501_MANUFAC_ID 0x87 +#define LTR501_ALS_DATA1 0x88 /* 16-bit, little endian */ +#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_ALS_CONTR_SW_RESET BIT(2) +#define LTR501_CONTR_PS_GAIN_MASK (BIT(3) | BIT(2)) +#define LTR501_CONTR_PS_GAIN_SHIFT 2 +#define LTR501_CONTR_ALS_GAIN_MASK BIT(3) +#define LTR501_CONTR_ACTIVE BIT(1) + +#define LTR501_STATUS_ALS_RDY BIT(2) +#define LTR501_STATUS_PS_RDY BIT(0) + +#define LTR501_PS_DATA_MASK 0x7ff + +struct ltr501_data { + struct i2c_client *client; + struct mutex lock_als, lock_ps; + u8 als_contr, ps_contr; +}; + +static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask) +{ + int tries = 100; + int ret; + + while (tries--) { + ret = i2c_smbus_read_byte_data(data->client, + LTR501_ALS_PS_STATUS); + if (ret < 0) + return ret; + if ((ret & drdy_mask) == drdy_mask) + return 0; + msleep(25); + } + + dev_err(&data->client->dev, "ltr501_drdy() failed, data not ready\n"); + return -EIO; +} + +static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2]) +{ + int 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); +} + +static int ltr501_read_ps(struct ltr501_data *data) +{ + int ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY); + if (ret < 0) + return ret; + return i2c_smbus_read_word_data(data->client, LTR501_PS_DATA); +} + +#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared) { \ + .type = IIO_INTENSITY, \ + .modified = 1, \ + .address = (_addr), \ + .channel2 = (_mod), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = (_shared), \ + .scan_index = (_idx), \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + } \ +} + +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)), + { + .type = IIO_PROXIMITY, + .address = LTR501_PS_DATA, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .scan_index = 2, + .scan_type = { + .sign = 'u', + .realbits = 11, + .storagebits = 16, + .endianness = IIO_CPU, + }, + }, + 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) +{ + struct ltr501_data *data = iio_priv(indio_dev); + __le16 buf[2]; + int ret, i; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; + + switch (chan->type) { + case IIO_INTENSITY: + mutex_lock(&data->lock_als); + ret = ltr501_read_als(data, buf); + mutex_unlock(&data->lock_als); + if (ret < 0) + return ret; + *val = le16_to_cpu(chan->address == LTR501_ALS_DATA1 ? + buf[0] : buf[1]); + return IIO_VAL_INT; + case IIO_PROXIMITY: + mutex_lock(&data->lock_ps); + ret = ltr501_read_ps(data); + mutex_unlock(&data->lock_ps); + if (ret < 0) + return ret; + *val = ret & LTR501_PS_DATA_MASK; + return IIO_VAL_INT; + default: + return -EINVAL; + } + 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; + } else { + *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; + *val = ltr501_ps_gain[i][0]; + *val2 = ltr501_ps_gain[i][1]; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + } + return -EINVAL; +} + +static int ltr501_get_ps_gain_index(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]) + return i; + + return -1; +} + +static int ltr501_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct ltr501_data *data = iio_priv(indio_dev); + int i; + + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; + + switch (mask) { + 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 + return -EINVAL; + return i2c_smbus_write_byte_data(data->client, + 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); + 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 struct attribute *ltr501_attributes[] = { + &iio_const_attr_in_proximity_scale_available.dev_attr.attr, + &iio_const_attr_in_intensity_scale_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group ltr501_attribute_group = { + .attrs = ltr501_attributes, +}; + +static const struct iio_info ltr501_info = { + .read_raw = ltr501_read_raw, + .write_raw = ltr501_write_raw, + .attrs = <r501_attribute_group, + .driver_module = THIS_MODULE, +}; + +static int ltr501_write_contr(struct i2c_client *client, u8 als_val, u8 ps_val) +{ + int ret = i2c_smbus_write_byte_data(client, LTR501_ALS_CONTR, als_val); + if (ret < 0) + return ret; + + return i2c_smbus_write_byte_data(client, LTR501_PS_CONTR, ps_val); +} + +static irqreturn_t ltr501_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ltr501_data *data = iio_priv(indio_dev); + u16 buf[8]; + __le16 als_buf[2]; + u8 mask = 0; + int j = 0; + int ret; + + memset(buf, 0, sizeof(buf)); + + /* 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)) + mask |= LTR501_STATUS_ALS_RDY; + if (test_bit(2, indio_dev->active_scan_mask)) + mask |= LTR501_STATUS_PS_RDY; + + ret = ltr501_drdy(data, mask); + if (ret < 0) + 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); + if (ret < 0) + return ret; + if (test_bit(0, indio_dev->active_scan_mask)) + buf[j++] = le16_to_cpu(als_buf[1]); + if (test_bit(1, indio_dev->active_scan_mask)) + buf[j++] = le16_to_cpu(als_buf[0]); + } + + if (mask & LTR501_STATUS_PS_RDY) { + ret = i2c_smbus_read_word_data(data->client, LTR501_PS_DATA); + if (ret < 0) + goto done; + buf[j++] = ret & LTR501_PS_DATA_MASK; + } + + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns()); + +done: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static int ltr501_init(struct ltr501_data *data) +{ + int ret; + + ret = i2c_smbus_read_byte_data(data->client, LTR501_ALS_CONTR); + if (ret < 0) + return ret; + data->als_contr = ret | LTR501_CONTR_ACTIVE; + + ret = i2c_smbus_read_byte_data(data->client, LTR501_PS_CONTR); + if (ret < 0) + return ret; + data->ps_contr = ret | LTR501_CONTR_ACTIVE; + + return ltr501_write_contr(data->client, data->als_contr, + data->ps_contr); +} + +static int ltr501_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct ltr501_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->lock_als); + mutex_init(&data->lock_ps); + + ret = i2c_smbus_read_byte_data(data->client, LTR501_PART_ID); + if (ret < 0) + return ret; + if ((ret >> 4) != 0x8) + 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; + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = ltr501_init(data); + if (ret < 0) + return ret; + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + ltr501_trigger_handler, NULL); + if (ret) + return ret; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_buffer; + + return 0; + +error_unreg_buffer: + iio_triggered_buffer_cleanup(indio_dev); + return ret; +} + +static int ltr501_powerdown(struct ltr501_data *data) +{ + return ltr501_write_contr(data->client, + data->als_contr & ~LTR501_CONTR_ACTIVE, + data->ps_contr & ~LTR501_CONTR_ACTIVE); +} + +static int ltr501_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); + ltr501_powerdown(iio_priv(indio_dev)); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int ltr501_suspend(struct device *dev) +{ + struct ltr501_data *data = iio_priv(i2c_get_clientdata( + 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))); + + return ltr501_write_contr(data->client, data->als_contr, + data->ps_contr); +} +#endif + +static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume); + +static const struct i2c_device_id ltr501_id[] = { + { "ltr501", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ltr501_id); + +static struct i2c_driver ltr501_driver = { + .driver = { + .name = LTR501_DRV_NAME, + .pm = <r501_pm_ops, + .owner = THIS_MODULE, + }, + .probe = ltr501_probe, + .remove = ltr501_remove, + .id_table = ltr501_id, +}; + +module_i2c_driver(ltr501_driver); + +MODULE_AUTHOR("Peter Meerwald "); +MODULE_DESCRIPTION("Lite-On LTR501 ambient light and proximity sensor driver"); +MODULE_LICENSE("GPL"); From e6869759e06fde902828700a2d7c4a15d34c8d10 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 13 Jan 2014 21:16:00 +0000 Subject: [PATCH 0009/1375] staging:iio:accel:sca3000: Fix kerneldoc match function names with kerneldoc Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 7f6ccdfaf168..908d5cde9b91 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -250,9 +250,8 @@ error_ret: } #endif /* SCA3000_DEBUG */ - /** - * sca3000_show_reg() - sysfs interface to read the chip revision number + * sca3000_show_rev() - sysfs interface to read the chip revision number **/ static ssize_t sca3000_show_rev(struct device *dev, struct device_attribute *attr, @@ -312,7 +311,7 @@ sca3000_show_available_measurement_modes(struct device *dev, } /** - * sca3000_show_measurmenet_mode() sysfs read of current mode + * sca3000_show_measurement_mode() sysfs read of current mode **/ static ssize_t sca3000_show_measurement_mode(struct device *dev, @@ -547,7 +546,7 @@ error_ret: return ret; } /** - * __sca3000_get_base_frequency() obtain mode specific base frequency + * __sca3000_get_base_freq() obtain mode specific base frequency * * lock must be held **/ @@ -972,7 +971,7 @@ error_ret: } /** - * sca3000_set_mo_det() simple on off control for motion detector + * sca3000_write_event_config() simple on off control for motion detector * * This is a per axis control, but enabling any will result in the * motion detector unit being enabled. From 5262d8fdd9cdc8ef3ad8e1af8968f079dd81dde5 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 13 Jan 2014 21:28:00 +0000 Subject: [PATCH 0010/1375] staging:iio:accel:sca3000: Fix format of comments Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 52 +++++++++++++----------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 908d5cde9b91..b627d8f6085d 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -32,7 +32,8 @@ enum sca3000_variant { e05, }; -/* Note where option modes are not defined, the chip simply does not +/* + * Note where option modes are not defined, the chip simply does not * support any. * Other chips in the sca3000 series use i2c and are not included here. * @@ -191,7 +192,6 @@ error_ret: return ret; } -/* Crucial that lock is called before calling this */ /** * sca3000_read_ctrl_reg() read from lock protected control register. * @@ -402,7 +402,8 @@ error_ret: } -/* Not even vaguely standard attributes so defined here rather than +/* + * Not even vaguely standard attributes so defined here rather than * in the relevant IIO core headers */ static IIO_DEVICE_ATTR(measurement_mode_available, S_IRUGO, @@ -662,7 +663,8 @@ error_free_lock: return ret ? ret : len; } -/* Should only really be registered if ring buffer support is compiled in. +/* + * Should only really be registered if ring buffer support is compiled in. * Does no harm however and doing it right would add a fair bit of complexity */ static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(sca3000_read_av_freq); @@ -675,10 +677,10 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, /** * sca3000_read_temp() sysfs interface to get the temperature when available * -* The alignment of data in here is downright odd. See data sheet. -* Converting this into a meaningful value is left to inline functions in -* userspace part of header. -**/ + * The alignment of data in here is downright odd. See data sheet. + * Converting this into a meaningful value is left to inline functions in + * userspace part of header. + **/ static ssize_t sca3000_read_temp(struct device *dev, struct device_attribute *attr, char *buf) @@ -802,12 +804,12 @@ static const struct attribute_group sca3000_attribute_group_with_temp = { .attrs = sca3000_attributes_with_temp, }; -/* RING RELATED interrupt handler */ -/* depending on event, push to the ring buffer event chrdev or the event one */ - /** * sca3000_event_handler() - handling ring and non ring events * + * Ring related interrupt handler. Depending on event, push to + * the ring buffer event chrdev or the event one. + * * This function is complicated by the fact that the devices can signify ring * and non ring events via the same interrupt line and they can only * be distinguished via a read of the relevant status register. @@ -819,7 +821,8 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) int ret, val; s64 last_timestamp = iio_get_time_ns(); - /* Could lead if badly timed to an extra read of status reg, + /* + * Could lead if badly timed to an extra read of status reg, * but ensures no interrupt is missed. */ mutex_lock(&st->lock); @@ -934,7 +937,6 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev, * the device falls more than 25cm. This has not been tested due * to fragile wiring. **/ - static ssize_t sca3000_set_free_fall_mode(struct device *dev, struct device_attribute *attr, const char *buf, @@ -956,7 +958,7 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev, if (ret) goto error_ret; - /*if off and should be on*/ + /* if off and should be on */ if (val && !(st->rx[0] & protect_mask)) ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, (st->rx[0] | SCA3000_FREE_FALL_DETECT)); @@ -991,13 +993,15 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev, int num = chan->channel2; mutex_lock(&st->lock); - /* First read the motion detector config to find out if - * this axis is on*/ + /* + * First read the motion detector config to find out if + * this axis is on + */ ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL); if (ret < 0) goto exit_point; ctrlval = ret; - /* Off and should be on */ + /* if off and should be on */ if (state && !(ctrlval & sca3000_addresses[num][2])) { ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL, @@ -1020,7 +1024,7 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev, ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1); if (ret) goto exit_point; - /*if off and should be on*/ + /* if off and should be on */ if ((st->mo_det_use_count) && ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET)) ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, @@ -1066,7 +1070,7 @@ static struct attribute_group sca3000_event_attribute_group = { * Devices use flash memory to store many of the register values * and hence can come up in somewhat unpredictable states. * Hence reset everything on driver load. - **/ + **/ static int sca3000_clean_setup(struct sca3000_state *st) { int ret; @@ -1106,9 +1110,11 @@ static int sca3000_clean_setup(struct sca3000_state *st) | SCA3000_INT_MASK_ACTIVE_LOW); if (ret) goto error_ret; - /* Select normal measurement mode, free fall off, ring off */ - /* Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5 - * as that occurs in one of the example on the datasheet */ + /* + * Select normal measurement mode, free fall off, ring off + * Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5 + * as that occurs in one of the example on the datasheet + */ ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1); if (ret) goto error_ret; @@ -1235,7 +1241,7 @@ static int sca3000_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct sca3000_state *st = iio_priv(indio_dev); - /* Must ensure no interrupts can be generated after this!*/ + /* Must ensure no interrupts can be generated after this! */ sca3000_stop_all_interrupts(st); if (spi->irq) free_irq(spi->irq, indio_dev); From 84bb9cdd035ee6ed63371ae926ed225ba51770f2 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 13 Jan 2014 21:28:00 +0000 Subject: [PATCH 0011/1375] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp issue introduced here 6fe8135f: staging:iio: implement an iio_info structure to take some of the constant elements out of iio_dev Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index b627d8f6085d..159272e9de9e 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1141,6 +1141,7 @@ static const struct iio_info sca3000_info = { static const struct iio_info sca3000_info_with_temp = { .attrs = &sca3000_attribute_group_with_temp, .read_raw = &sca3000_read_raw, + .event_attrs = &sca3000_event_attribute_group, .read_event_value = &sca3000_read_thresh, .write_event_value = &sca3000_write_thresh, .read_event_config = &sca3000_read_event_config, From 735165a8ee2ba5de723f014f4d6e77f99a51df62 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 13 Jan 2014 21:28:00 +0000 Subject: [PATCH 0012/1375] staging:iio:accel:sca3000: Channels missing in temp_output case issues introduced here 25888dc5, staging:iio:sca3000 extract old event handling and move to poll for events Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 159272e9de9e..0123bc0f2922 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1170,11 +1170,10 @@ static int sca3000_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; if (st->info->temp_output) indio_dev->info = &sca3000_info_with_temp; - else { + else indio_dev->info = &sca3000_info; - indio_dev->channels = sca3000_channels; - indio_dev->num_channels = ARRAY_SIZE(sca3000_channels); - } + indio_dev->channels = sca3000_channels; + indio_dev->num_channels = ARRAY_SIZE(sca3000_channels); indio_dev->modes = INDIO_DIRECT_MODE; sca3000_configure_ring(indio_dev); From bb0090e99b0194c76d2c46327f9d9dc9bba1c590 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 13 Jan 2014 21:28:00 +0000 Subject: [PATCH 0013/1375] staging:iio:accel:sca3000: Move temperature attribute to channels differantiate between channels with_temp and without Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 125 +++++++++-------------- 1 file changed, 48 insertions(+), 77 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 0123bc0f2922..ed30e32e60de 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -450,6 +450,18 @@ static const struct iio_chan_spec sca3000_channels[] = { SCA3000_CHAN(2, IIO_MOD_Z), }; +static const struct iio_chan_spec sca3000_channels_with_temp[] = { + SCA3000_CHAN(0, IIO_MOD_X), + SCA3000_CHAN(1, IIO_MOD_Y), + SCA3000_CHAN(2, IIO_MOD_Z), + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET), + }, +}; + static u8 sca3000_addresses[3][3] = { [0] = {SCA3000_REG_ADDR_X_MSB, SCA3000_REG_CTRL_SEL_MD_X_TH, SCA3000_MD_CTRL_OR_X}, @@ -472,19 +484,30 @@ static int sca3000_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: mutex_lock(&st->lock); - if (st->mo_det_use_count) { - mutex_unlock(&st->lock); - return -EBUSY; + if (chan->type == IIO_ACCEL) { + if (st->mo_det_use_count) { + mutex_unlock(&st->lock); + return -EBUSY; + } + address = sca3000_addresses[chan->address][0]; + ret = sca3000_read_data_short(st, address, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF; + *val = ((*val) << (sizeof(*val)*8 - 13)) >> + (sizeof(*val)*8 - 13); + } else { + /* get the temperature when available */ + ret = sca3000_read_data_short(st, + SCA3000_REG_ADDR_TEMP_MSB, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + *val = ((st->rx[0] & 0x3F) << 3) | ((st->rx[1] & 0xE0) >> 5); } - address = sca3000_addresses[chan->address][0]; - ret = sca3000_read_data_short(st, address, 2); - if (ret < 0) { - mutex_unlock(&st->lock); - return ret; - } - *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF; - *val = ((*val) << (sizeof(*val)*8 - 13)) >> - (sizeof(*val)*8 - 13); mutex_unlock(&st->lock); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: @@ -494,6 +517,10 @@ static int sca3000_read_raw(struct iio_dev *indio_dev, else /* temperature */ *val2 = 555556; return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_OFFSET: + *val = -214; + *val2 = 600000; + return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; } @@ -673,37 +700,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, sca3000_read_frequency, sca3000_set_frequency); - -/** - * sca3000_read_temp() sysfs interface to get the temperature when available - * - * The alignment of data in here is downright odd. See data sheet. - * Converting this into a meaningful value is left to inline functions in - * userspace part of header. - **/ -static ssize_t sca3000_read_temp(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct sca3000_state *st = iio_priv(indio_dev); - int ret; - int val; - ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_TEMP_MSB, 2); - if (ret < 0) - goto error_ret; - val = ((st->rx[0] & 0x3F) << 3) | ((st->rx[1] & 0xE0) >> 5); - - return sprintf(buf, "%d\n", val); - -error_ret: - return ret; -} -static IIO_DEV_ATTR_TEMP_RAW(sca3000_read_temp); - -static IIO_CONST_ATTR_TEMP_SCALE("0.555556"); -static IIO_CONST_ATTR_TEMP_OFFSET("-214.6"); - /** * sca3000_read_thresh() - query of a threshold **/ @@ -783,27 +779,10 @@ static struct attribute *sca3000_attributes[] = { NULL, }; -static struct attribute *sca3000_attributes_with_temp[] = { - &iio_dev_attr_revision.dev_attr.attr, - &iio_dev_attr_measurement_mode_available.dev_attr.attr, - &iio_dev_attr_measurement_mode.dev_attr.attr, - &iio_dev_attr_sampling_frequency_available.dev_attr.attr, - &iio_dev_attr_sampling_frequency.dev_attr.attr, - /* Only present if temp sensor is */ - &iio_dev_attr_in_temp_raw.dev_attr.attr, - &iio_const_attr_in_temp_offset.dev_attr.attr, - &iio_const_attr_in_temp_scale.dev_attr.attr, - NULL, -}; - static const struct attribute_group sca3000_attribute_group = { .attrs = sca3000_attributes, }; -static const struct attribute_group sca3000_attribute_group_with_temp = { - .attrs = sca3000_attributes_with_temp, -}; - /** * sca3000_event_handler() - handling ring and non ring events * @@ -1138,17 +1117,6 @@ static const struct iio_info sca3000_info = { .driver_module = THIS_MODULE, }; -static const struct iio_info sca3000_info_with_temp = { - .attrs = &sca3000_attribute_group_with_temp, - .read_raw = &sca3000_read_raw, - .event_attrs = &sca3000_event_attribute_group, - .read_event_value = &sca3000_read_thresh, - .write_event_value = &sca3000_write_thresh, - .read_event_config = &sca3000_read_event_config, - .write_event_config = &sca3000_write_event_config, - .driver_module = THIS_MODULE, -}; - static int sca3000_probe(struct spi_device *spi) { int ret; @@ -1168,12 +1136,15 @@ static int sca3000_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; - if (st->info->temp_output) - indio_dev->info = &sca3000_info_with_temp; - else - indio_dev->info = &sca3000_info; - indio_dev->channels = sca3000_channels; - indio_dev->num_channels = ARRAY_SIZE(sca3000_channels); + indio_dev->info = &sca3000_info; + if (st->info->temp_output) { + indio_dev->channels = sca3000_channels_with_temp; + indio_dev->num_channels = + ARRAY_SIZE(sca3000_channels_with_temp); + } else { + indio_dev->channels = sca3000_channels; + indio_dev->num_channels = ARRAY_SIZE(sca3000_channels); + } indio_dev->modes = INDIO_DIRECT_MODE; sca3000_configure_ring(indio_dev); From 1a0e576661487db2c7a2b4c7844ea38c46beda9e Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 13 Jan 2014 21:28:00 +0000 Subject: [PATCH 0014/1375] staging:iio:accel:sca3000: Cleanup sca3000.h kerneldoc and comment formating, typos Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h index c1016c510dae..b284e5a6cac1 100644 --- a/drivers/staging/iio/accel/sca3000.h +++ b/drivers/staging/iio/accel/sca3000.h @@ -65,7 +65,8 @@ #define SCA3000_RING_BUF_ENABLE 0x80 #define SCA3000_RING_BUF_8BIT 0x40 -/* Free fall detection triggers an interrupt if the acceleration +/* + * Free fall detection triggers an interrupt if the acceleration * is below a threshold for equivalent of 25cm drop */ #define SCA3000_FREE_FALL_DETECT 0x10 @@ -73,8 +74,9 @@ #define SCA3000_MEAS_MODE_OP_1 0x01 #define SCA3000_MEAS_MODE_OP_2 0x02 -/* In motion detection mode the accelerations are band pass filtered - * (aprox 1 - 25Hz) and then a programmable threshold used to trigger +/* + * In motion detection mode the accelerations are band pass filtered + * (approx 1 - 25Hz) and then a programmable threshold used to trigger * and interrupt. */ #define SCA3000_MEAS_MODE_MOT_DET 0x03 @@ -99,8 +101,10 @@ #define SCA3000_REG_CTRL_SEL_MD_Y_TH 0x03 #define SCA3000_REG_CTRL_SEL_MD_X_TH 0x04 #define SCA3000_REG_CTRL_SEL_MD_Z_TH 0x05 -/* BE VERY CAREFUL WITH THIS, IF 3 BITS ARE NOT SET the device - will not function */ +/* + * BE VERY CAREFUL WITH THIS, IF 3 BITS ARE NOT SET the device + * will not function + */ #define SCA3000_REG_CTRL_SEL_OUT_CTRL 0x0B #define SCA3000_OUT_CTRL_PROT_MASK 0xE0 #define SCA3000_OUT_CTRL_BUF_X_EN 0x10 @@ -109,8 +113,9 @@ #define SCA3000_OUT_CTRL_BUF_DIV_4 0x02 #define SCA3000_OUT_CTRL_BUF_DIV_2 0x01 -/* Control which motion detector interrupts are on. - * For now only OR combinations are supported.x +/* + * Control which motion detector interrupts are on. + * For now only OR combinations are supported. */ #define SCA3000_MD_CTRL_PROT_MASK 0xC0 #define SCA3000_MD_CTRL_OR_Y 0x01 @@ -121,7 +126,8 @@ #define SCA3000_MD_CTRL_AND_X 0x10 #define SAC3000_MD_CTRL_AND_Z 0x20 -/* Some control registers of complex access methods requiring this register to +/* + * Some control registers of complex access methods requiring this register to * be used to remove a lock. */ #define SCA3000_REG_ADDR_UNLOCK 0x1e @@ -139,7 +145,8 @@ /* Values of multiplexed registers (write to ctrl_data after select) */ #define SCA3000_REG_ADDR_CTRL_DATA 0x22 -/* Measurement modes available on some sca3000 series chips. Code assumes others +/* + * Measurement modes available on some sca3000 series chips. Code assumes others * may become available in the future. * * Bypass - Bypass the low-pass filter in the signal channel so as to increase @@ -160,7 +167,6 @@ * struct sca3000_state - device instance state information * @us: the associated spi device * @info: chip variant information - * @indio_dev: device information used by the IIO core * @interrupt_handler_ws: event interrupt handler for all events * @last_timestamp: the timestamp of the last event * @mo_det_use_count: reference counter for the motion detection unit From c842f241956f880fbba9bc041b196a249f80d131 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 18 Jan 2014 19:05:00 +0000 Subject: [PATCH 0015/1375] iio: mxs-lradc: remove useless check Checking the channel number is useless since mxs_lradc_read_raw() is called from a controlled environment and the driver is responsible for filing the struct iio_chan_spec. Signed-off-by: Alexandre Belloni Acked-by: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index df71669bb60e..7b9224198bb8 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -897,10 +897,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, { struct mxs_lradc *lradc = iio_priv(iio_dev); - /* Check for invalid channel */ - if (chan->channel > LRADC_MAX_TOTAL_CHANS) - return -EINVAL; - switch (m) { case IIO_CHAN_INFO_RAW: if (chan->type == IIO_TEMP) From 97b6ee5253021d890eb9fdd95e0b64fd95494824 Mon Sep 17 00:00:00 2001 From: Johannes Thumshirn Date: Thu, 2 Jan 2014 14:52:00 +0000 Subject: [PATCH 0016/1375] iio: adc: viperboard: Drop platform_set_drvdata call Drop call to platform_set_drvdata as driver data is not used anywhere in the driver Signed-off-by: Johannes Thumshirn Signed-off-by: Jonathan Cameron --- drivers/iio/adc/viperboard_adc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c index d0add8f9416b..9acf6b6d705b 100644 --- a/drivers/iio/adc/viperboard_adc.c +++ b/drivers/iio/adc/viperboard_adc.c @@ -139,8 +139,6 @@ static int vprbrd_adc_probe(struct platform_device *pdev) return ret; } - platform_set_drvdata(pdev, indio_dev); - return 0; } From 7638c2ed9c1df35ea74ea992df6ea380c9f842e3 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 30 Jan 2014 11:59:00 +0000 Subject: [PATCH 0017/1375] iio:imu:adis16400 remove an unneeded check We know "ret" is zero here so there is no need to check. Signed-off-by: Dan Carpenter Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis16400_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 368660dfe135..411586f49dae 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c @@ -281,7 +281,7 @@ static ssize_t adis16400_write_frequency(struct device *dev, st->variant->set_freq(st, val); mutex_unlock(&indio_dev->mlock); - return ret ? ret : len; + return len; } /* Power down the device */ From a04cf55a527896058ea53c3840fa1f075df35720 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 30 Jan 2014 11:58:00 +0000 Subject: [PATCH 0018/1375] iio: dac: ad7303: remove an unneeded check "ret" is zero here. There is no need to check again. Signed-off-by: Dan Carpenter Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad7303.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index d0505fd22ef4..fa2810032968 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -92,7 +92,7 @@ static ssize_t ad7303_write_dac_powerdown(struct iio_dev *indio_dev, ad7303_write(st, chan->channel, st->dac_cache[chan->channel]); mutex_unlock(&indio_dev->mlock); - return ret ? ret : len; + return len; } static int ad7303_get_vref(struct ad7303_state *st, From 3ea8f3bcabe422c6b5778089ae0929c1028e58f8 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Wed, 22 Jan 2014 21:36:12 +0800 Subject: [PATCH 0019/1375] staging/lustre/llite: remove ll_d_root_ops Mnt root dentry will never be revalidated, but its d_op->d_compare will be called for its children, to simplify code, we use the same ll_d_ops as normal dentries. But its attribute may be invalid before access, this won't cause any issue because it always exists, and the only operation depends on its attribute is .permission, which has revalidated it in lustre code. So it's okay to remove ll_d_root_ops, and remove unnecessary checks in lookup/revalidate/statahead. Lustre-change: http://review.whamcloud.com/6797 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3486 Signed-off-by: Lai Siyao Reviewed-by: James Simmons Reviewed-by: Peng Tao Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Reviewed-by: Alexey Shvetsov Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dcache.c | 40 ++++--------------- .../lustre/lustre/llite/llite_internal.h | 5 ++- .../staging/lustre/lustre/llite/llite_lib.c | 11 +---- .../staging/lustre/lustre/llite/llite_nfs.c | 6 +-- drivers/staging/lustre/lustre/llite/namei.c | 28 ++++++------- .../staging/lustre/lustre/llite/statahead.c | 7 ++-- 6 files changed, 33 insertions(+), 64 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index cbd663ed030c..3907c87c2ba1 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -176,7 +176,7 @@ static int ll_ddelete(const struct dentry *de) return 0; } -static int ll_set_dd(struct dentry *de) +int ll_d_init(struct dentry *de) { LASSERT(de != NULL); @@ -190,40 +190,22 @@ static int ll_set_dd(struct dentry *de) OBD_ALLOC_PTR(lld); if (likely(lld != NULL)) { spin_lock(&de->d_lock); - if (likely(de->d_fsdata == NULL)) + if (likely(de->d_fsdata == NULL)) { de->d_fsdata = lld; - else + __d_lustre_invalidate(de); + } else { OBD_FREE_PTR(lld); + } spin_unlock(&de->d_lock); } else { return -ENOMEM; } } + LASSERT(de->d_op == &ll_d_ops); return 0; } -int ll_dops_init(struct dentry *de, int block, int init_sa) -{ - struct ll_dentry_data *lld = ll_d2d(de); - int rc = 0; - - if (lld == NULL && block != 0) { - rc = ll_set_dd(de); - if (rc) - return rc; - - lld = ll_d2d(de); - } - - if (lld != NULL && init_sa != 0) - lld->lld_sa_generation = 0; - - /* kernel >= 2.6.38 d_op is set in d_alloc() */ - LASSERT(de->d_op == &ll_d_ops); - return rc; -} - void ll_intent_drop_lock(struct lookup_intent *it) { if (it->it_op && it->d.lustre.it_lock_mode) { @@ -359,6 +341,8 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, CDEBUG(D_VFSTRACE, "VFS Op:name=%s,intent=%s\n", de->d_name.name, LL_IT2STR(it)); + LASSERT(de != de->d_sb->s_root); + if (de->d_inode == NULL) { __u64 ibits; @@ -383,14 +367,6 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, if (d_mountpoint(de)) GOTO(out_sa, rc = 1); - /* need to get attributes in case root got changed from other client */ - if (de == de->d_sb->s_root) { - rc = __ll_inode_revalidate_it(de, it, MDS_INODELOCK_LOOKUP); - if (rc == 0) - rc = 1; - GOTO(out_sa, rc); - } - exp = ll_i2mdexp(de->d_inode); OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5); diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 7ee5c02783f9..28669eafb396 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -828,7 +828,7 @@ int ll_lease_close(struct obd_client_handle *och, struct inode *inode, /* llite/dcache.c */ -int ll_dops_init(struct dentry *de, int block, int init_sa); +int ll_d_init(struct dentry *de); extern struct dentry_operations ll_d_ops; void ll_intent_drop_lock(struct lookup_intent *); void ll_intent_release(struct lookup_intent *); @@ -1320,7 +1320,8 @@ ll_statahead_mark(struct inode *dir, struct dentry *dentry) if (lli->lli_opendir_pid != current_pid()) return; - if (sai != NULL && ldd != NULL) + LASSERT(ldd != NULL); + if (sai != NULL) ldd->lld_sa_generation = sai->sai_generation; } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 6cfdb9e4b74b..70a68088138c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -155,11 +155,6 @@ void ll_free_sbi(struct super_block *sb) } } -static struct dentry_operations ll_d_root_ops = { - .d_compare = ll_dcompare, - .d_revalidate = ll_revalidate_nd, -}; - static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct vfsmount *mnt) { @@ -579,10 +574,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, GOTO(out_root, err = -ENOMEM); } - /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ - d_set_d_op(sb->s_root, &ll_d_root_ops); - sb->s_d_op = &ll_d_ops; - sbi->ll_sdev_orig = sb->s_dev; /* We set sb->s_dev equal on all lustre clients in order to support @@ -1013,6 +1004,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) GOTO(out_free, err); sb->s_bdi = &lsi->lsi_bdi; + /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ + sb->s_d_op = &ll_d_ops; /* Generate a string unique to this super, in case some joker tries to mount the same fs at two mount points. diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 1767c741fb72..3580069789fc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -167,10 +167,10 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren } result = d_obtain_alias(inode); - if (IS_ERR(result)) + if (IS_ERR(result)) { + iput(inode); return result; - - ll_dops_init(result, 1, 0); + } return result; } diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index fc8d264f6c9a..bc1a644aa502 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -400,11 +400,16 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de) { struct dentry *new; + int rc; if (inode) { new = ll_find_alias(inode, de); if (new) { - ll_dops_init(new, 1, 1); + rc = ll_d_init(new); + if (rc < 0) { + dput(new); + return ERR_PTR(rc); + } d_move(new, de); iput(inode); CDEBUG(D_DENTRY, @@ -413,8 +418,9 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de) return new; } } - ll_dops_init(de, 1, 1); - __d_lustre_invalidate(de); + rc = ll_d_init(de); + if (rc < 0) + return ERR_PTR(rc); d_add(de, inode); CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n", de, de->d_inode, d_count(de), de->d_flags); @@ -455,8 +461,11 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, /* Only hash *de if it is unhashed (new dentry). * Atoimc_open may passin hashed dentries for open. */ - if (d_unhashed(*de)) + if (d_unhashed(*de)) { *de = ll_splice_alias(inode, *de); + if (IS_ERR(*de)) + return PTR_ERR(*de); + } if (!it_disposition(it, DISP_LOOKUP_NEG)) { /* we have lookup look - unhide dentry */ @@ -505,16 +514,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, ll_frob_intent(&it, &lookup_it); - /* As do_lookup is called before follow_mount, root dentry may be left - * not valid, revalidate it here. */ - if (parent->i_sb->s_root && (parent->i_sb->s_root->d_inode == parent) && - (it->it_op & (IT_OPEN | IT_CREAT))) { - rc = ll_inode_revalidate_it(parent->i_sb->s_root, it, - MDS_INODELOCK_LOOKUP); - if (rc) - return ERR_PTR(rc); - } - if (it->it_op == IT_GETATTR) { rc = ll_statahead_enter(parent, &dentry, 0); if (rc == 1) { @@ -585,7 +584,6 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, /* Optimize away (CREATE && !OPEN). Let .create handle the race. */ if ((flags & LOOKUP_CREATE ) && !(flags & LOOKUP_OPEN)) { - ll_dops_init(dentry, 1, 1); __d_lustre_invalidate(dentry); d_add(dentry, NULL); return NULL; diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index f6b5f4b95f37..183b4157a7d8 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -877,9 +877,6 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, if (d_mountpoint(dentry)) return 1; - if (unlikely(dentry == dentry->d_sb->s_root)) - return 1; - entry->se_inode = igrab(inode); rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode),NULL); if (rc == 1) { @@ -1590,6 +1587,10 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, if ((*dentryp)->d_inode == NULL) { *dentryp = ll_splice_alias(inode, *dentryp); + if (IS_ERR(*dentryp)) { + ll_sai_unplug(sai, entry); + return PTR_ERR(*dentryp); + } } else if ((*dentryp)->d_inode != inode) { /* revalidate, but inode is recreated */ CDEBUG(D_READA, From 4f2fb455a1dcdf3cacf30382460c3706cf7e66d1 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Wed, 22 Jan 2014 21:36:13 +0800 Subject: [PATCH 0020/1375] staging/lustre/llite: don't d_add for create only files This is only part of the original Lustre commit. Splitted to remove d_add() for create only files, because the dentry is fake, and will be released right after use. Lustre-change: http://review.whamcloud.com/6797 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3486 Signed-off-by: Lai Siyao Reviewed-by: James Simmons Reviewed-by: Peng Tao Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Reviewed-by: Alexey Shvetsov Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/namei.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index bc1a644aa502..1d03a6f8e4ad 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -583,11 +583,8 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, parent->i_generation, parent, flags); /* Optimize away (CREATE && !OPEN). Let .create handle the race. */ - if ((flags & LOOKUP_CREATE ) && !(flags & LOOKUP_OPEN)) { - __d_lustre_invalidate(dentry); - d_add(dentry, NULL); + if ((flags & LOOKUP_CREATE) && !(flags & LOOKUP_OPEN)) return NULL; - } if (flags & (LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE)) itp = NULL; From b0337d6c101bbb5be0fe249c05373cce4d24986c Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 22 Jan 2014 21:36:14 +0800 Subject: [PATCH 0021/1375] staging/lustre/llite: pass correct pointer to obd_iocontrol() In copy_and_ioctl() use the kernel space copy as the karg to obd_iocontrol(). Lustre-change: http://review.whamcloud.com/6274 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3283 Signed-off-by: John L. Hammond Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 22d0acc95bc5..1b217c8802b0 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1048,20 +1048,25 @@ progress: } -static int copy_and_ioctl(int cmd, struct obd_export *exp, void *data, int len) +static int copy_and_ioctl(int cmd, struct obd_export *exp, + const void __user *data, size_t size) { - void *ptr; + void *copy; int rc; - OBD_ALLOC(ptr, len); - if (ptr == NULL) + OBD_ALLOC(copy, size); + if (copy == NULL) return -ENOMEM; - if (copy_from_user(ptr, data, len)) { - OBD_FREE(ptr, len); - return -EFAULT; + + if (copy_from_user(copy, data, size)) { + rc = -EFAULT; + goto out; } - rc = obd_iocontrol(cmd, exp, len, data, NULL); - OBD_FREE(ptr, len); + + rc = obd_iocontrol(cmd, exp, size, copy, NULL); +out: + OBD_FREE(copy, size); + return rc; } From f3418ce8a655e7750fd57a4d28c757c43464ac62 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 22 Jan 2014 21:36:15 +0800 Subject: [PATCH 0022/1375] staging/lustre/idl: remove LASSERT/CLASSERT from lustre_idl.h Remove the usage of LASSERT() and CLASSERT() from lustre_idl.h, so that it is usable from userspace programs if needed. These have crept in over the years, but are not intended to be there. The CLASSERT() checks for fid swabbing were largely redundant, and have been moved to lustre/fid/fid_handler.c. There are still a few LASSERTs that need to be removed when FID-on-OST is landed, but I don't want to remove them before that code lands. There are also uses of CERROR() that could be removed at that time. Lustre-change: http://review.whamcloud.com/5682 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1606 Signed-off-by: Andreas Dilger Signed-off-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Christopher J. Morrone Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 43 ++++--------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 5da31c54924a..ac7fb379bf74 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -91,8 +91,8 @@ #ifndef _LUSTRE_IDL_H_ #define _LUSTRE_IDL_H_ -#if !defined(LASSERT) && !defined(LPU64) -#include /* for LASSERT, LPUX64, etc */ +#if !defined(LPU64) +#include /* for LPUX64, etc */ #endif /* Defn's shared with user-space. */ @@ -232,7 +232,6 @@ static inline unsigned fld_range_is_any(const struct lu_seq_range *range) static inline void fld_range_set_type(struct lu_seq_range *range, unsigned flags) { - LASSERT(!(flags & ~LU_SEQ_RANGE_MASK)); range->lsr_flags |= flags; } @@ -615,7 +614,6 @@ static inline obd_id fid_idif_id(obd_seq seq, __u32 oid, __u32 ver) /* extract ost index from IDIF FID */ static inline __u32 fid_idif_ost_idx(const struct lu_fid *fid) { - LASSERT(fid_is_idif(fid)); return (fid_seq(fid) >> 16) & 0xffff; } @@ -833,11 +831,6 @@ static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen) */ static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) { - /* check that all fields are converted */ - CLASSERT(sizeof(*src) == - sizeof(fid_seq(src)) + - sizeof(fid_oid(src)) + - sizeof(fid_ver(src))); dst->f_seq = cpu_to_le64(fid_seq(src)); dst->f_oid = cpu_to_le32(fid_oid(src)); dst->f_ver = cpu_to_le32(fid_ver(src)); @@ -845,11 +838,6 @@ static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { - /* check that all fields are converted */ - CLASSERT(sizeof(*src) == - sizeof(fid_seq(src)) + - sizeof(fid_oid(src)) + - sizeof(fid_ver(src))); dst->f_seq = le64_to_cpu(fid_seq(src)); dst->f_oid = le32_to_cpu(fid_oid(src)); dst->f_ver = le32_to_cpu(fid_ver(src)); @@ -857,11 +845,6 @@ static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) { - /* check that all fields are converted */ - CLASSERT(sizeof(*src) == - sizeof(fid_seq(src)) + - sizeof(fid_oid(src)) + - sizeof(fid_ver(src))); dst->f_seq = cpu_to_be64(fid_seq(src)); dst->f_oid = cpu_to_be32(fid_oid(src)); dst->f_ver = cpu_to_be32(fid_ver(src)); @@ -869,11 +852,6 @@ static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { - /* check that all fields are converted */ - CLASSERT(sizeof(*src) == - sizeof(fid_seq(src)) + - sizeof(fid_oid(src)) + - sizeof(fid_ver(src))); dst->f_seq = be64_to_cpu(fid_seq(src)); dst->f_oid = be32_to_cpu(fid_oid(src)); dst->f_ver = be32_to_cpu(fid_ver(src)); @@ -897,11 +875,6 @@ extern void lustre_swab_lu_seq_range(struct lu_seq_range *range); static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) { - /* Check that there is no alignment padding. */ - CLASSERT(sizeof(*f0) == - sizeof(f0->f_seq) + - sizeof(f0->f_oid) + - sizeof(f0->f_ver)); return memcmp(f0, f1, sizeof(*f0)) == 0; } @@ -3328,9 +3301,10 @@ struct obdo { #define o_grant_used o_data_version static inline void lustre_set_wire_obdo(struct obd_connect_data *ocd, - struct obdo *wobdo, struct obdo *lobdo) + struct obdo *wobdo, + const struct obdo *lobdo) { - memcpy(wobdo, lobdo, sizeof(*lobdo)); + *wobdo = *lobdo; wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; if (ocd == NULL) return; @@ -3345,16 +3319,15 @@ static inline void lustre_set_wire_obdo(struct obd_connect_data *ocd, } static inline void lustre_get_wire_obdo(struct obd_connect_data *ocd, - struct obdo *lobdo, struct obdo *wobdo) + struct obdo *lobdo, + const struct obdo *wobdo) { obd_flag local_flags = 0; if (lobdo->o_valid & OBD_MD_FLFLAGS) local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; - LASSERT(!(wobdo->o_flags & OBD_FL_LOCAL_MASK)); - - memcpy(lobdo, wobdo, sizeof(*lobdo)); + *lobdo = *wobdo; if (local_flags != 0) { lobdo->o_valid |= OBD_MD_FLFLAGS; lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; From 7d4bae456cb1b3a92fb2d26e56c948cf4f05c950 Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Wed, 22 Jan 2014 21:36:16 +0800 Subject: [PATCH 0023/1375] staging/lustre/mgs: set_param -P option that sets value permanently set_param and conf_param have different syntaxes. Also conf_param has unimplemented paths and no wildcarding support. This patch adds set_param -P option, that replaces the whole conf_param "direct" proc access with a simple upcall-type mechanism from the MGC. Option conf_param is saved now for compatibility. Part of the original Lustre commit changes server code. The patch only picks up client side change. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3155 Lustre-change: http://review.whamcloud.com/6025 Signed-off-by: Artem Blagodarenko Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_cfg.h | 2 + .../lustre/lustre/include/lustre_disk.h | 2 + .../staging/lustre/lustre/include/obd_class.h | 9 +- .../staging/lustre/lustre/llite/llite_lib.c | 5 +- .../staging/lustre/lustre/mgc/mgc_request.c | 90 ++++++++++++++++--- .../lustre/lustre/obdclass/obd_config.c | 47 +++++++++- 6 files changed, 136 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index e14a5f674e85..3680668a8920 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -88,6 +88,8 @@ enum lcfg_command_type { LCFG_SET_LDLM_TIMEOUT = 0x00ce030, /**< set ldlm_timeout */ LCFG_PRE_CLEANUP = 0x00cf031, /**< call type-specific pre * cleanup cleanup */ + LCFG_SET_PARAM = 0x00ce032, /**< use set_param syntax to set + *a proc parameters */ }; struct lustre_cfg_bufs { diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 1de9a8bed497..ac08164793cb 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -99,6 +99,8 @@ #define LDD_F_IR_CAPABLE 0x2000 /** the MGS refused to register the target. */ #define LDD_F_ERROR 0x4000 +/** process at lctl conf_param */ +#define LDD_F_PARAM2 0x8000 /* opc for target register */ #define LDD_F_OPC_REG 0x10000000 diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 983718fe1e55..1c2ba19bd987 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -175,9 +175,13 @@ enum { CONFIG_T_CONFIG = 0, CONFIG_T_SPTLRPC = 1, CONFIG_T_RECOVER = 2, - CONFIG_T_MAX = 3 + CONFIG_T_PARAMS = 3, + CONFIG_T_MAX = 4 }; +#define PARAMS_FILENAME "params" +#define LCTL_UPCALL "lctl" + /* list of active configuration logs */ struct config_llog_data { struct ldlm_res_id cld_resid; @@ -185,7 +189,8 @@ struct config_llog_data { struct list_head cld_list_chain; atomic_t cld_refcount; struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */ - struct config_llog_data *cld_recover; /* imperative recover log */ + struct config_llog_data *cld_params; /* common parameters log */ + struct config_llog_data *cld_recover;/* imperative recover log */ struct obd_export *cld_mgcexp; struct mutex cld_lock; int cld_type; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 70a68088138c..3e4c292769e6 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1060,7 +1060,7 @@ out_free: void ll_put_super(struct super_block *sb) { - struct config_llog_instance cfg; + struct config_llog_instance cfg, params_cfg; struct obd_device *obd; struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1074,6 +1074,9 @@ void ll_put_super(struct super_block *sb) cfg.cfg_instance = sb; lustre_end_log(sb, profilenm, &cfg); + params_cfg.cfg_instance = sb; + lustre_end_log(sb, PARAMS_FILENAME, ¶ms_cfg); + if (sbi->ll_md_exp) { obd = class_exp2obd(sbi->ll_md_exp); if (obd) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 3bdbb94e020f..b391b05ab6f8 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -56,7 +56,7 @@ static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id, { __u64 resname = 0; - if (len > 8) { + if (len > sizeof(resname)) { CERROR("name too long: %s\n", name); return -EINVAL; } @@ -76,6 +76,7 @@ static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id, resname = 0; break; case CONFIG_T_RECOVER: + case CONFIG_T_PARAMS: resname = type; break; default: @@ -101,10 +102,13 @@ int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type) int len; /* logname consists of "fsname-nodetype". - * e.g. "lustre-MDT0001", "SUN-000-client" */ + * e.g. "lustre-MDT0001", "SUN-000-client" + * there is an exception: llog "params" */ name_end = strrchr(logname, '-'); - LASSERT(name_end); - len = name_end - logname; + if (!name_end) + len = strlen(logname); + else + len = name_end - logname; return mgc_name2resid(logname, len, res_id, type); } @@ -140,6 +144,8 @@ static void config_log_put(struct config_llog_data *cld) config_log_put(cld->cld_recover); if (cld->cld_sptlrpc) config_log_put(cld->cld_sptlrpc); + if (cld->cld_params) + config_log_put(cld->cld_params); if (cld_is_sptlrpc(cld)) sptlrpc_conf_log_stop(cld->cld_logname); @@ -271,6 +277,19 @@ static struct config_llog_data *config_recover_log_add(struct obd_device *obd, return cld; } +static struct config_llog_data *config_params_log_add(struct obd_device *obd, + struct config_llog_instance *cfg, struct super_block *sb) +{ + struct config_llog_instance lcfg = *cfg; + struct config_llog_data *cld; + + lcfg.cfg_instance = sb; + + cld = do_config_log_add(obd, PARAMS_FILENAME, CONFIG_T_PARAMS, + &lcfg, sb); + + return cld; +} /** Add this log to the list of active logs watched by an MGC. * Active means we're watching for updates. @@ -284,8 +303,10 @@ static int config_log_add(struct obd_device *obd, char *logname, struct lustre_sb_info *lsi = s2lsi(sb); struct config_llog_data *cld; struct config_llog_data *sptlrpc_cld; - char seclogname[32]; - char *ptr; + struct config_llog_data *params_cld; + char seclogname[32]; + char *ptr; + int rc; CDEBUG(D_MGC, "adding config log %s:%p\n", logname, cfg->cfg_instance); @@ -308,32 +329,49 @@ static int config_log_add(struct obd_device *obd, char *logname, CONFIG_T_SPTLRPC, NULL, NULL); if (IS_ERR(sptlrpc_cld)) { CERROR("can't create sptlrpc log: %s\n", seclogname); - return PTR_ERR(sptlrpc_cld); + GOTO(out_err, rc = PTR_ERR(sptlrpc_cld)); } } + params_cld = config_params_log_add(obd, cfg, sb); + if (IS_ERR(params_cld)) { + rc = PTR_ERR(params_cld); + CERROR("%s: can't create params log: rc = %d\n", + obd->obd_name, rc); + GOTO(out_err1, rc); + } cld = do_config_log_add(obd, logname, CONFIG_T_CONFIG, cfg, sb); if (IS_ERR(cld)) { CERROR("can't create log: %s\n", logname); - config_log_put(sptlrpc_cld); - return PTR_ERR(cld); + GOTO(out_err2, rc = PTR_ERR(cld)); } cld->cld_sptlrpc = sptlrpc_cld; + cld->cld_params = params_cld; LASSERT(lsi->lsi_lmd); if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)) { struct config_llog_data *recover_cld; *strrchr(seclogname, '-') = 0; recover_cld = config_recover_log_add(obd, seclogname, cfg, sb); - if (IS_ERR(recover_cld)) { - config_log_put(cld); - return PTR_ERR(recover_cld); - } + if (IS_ERR(recover_cld)) + GOTO(out_err3, rc = PTR_ERR(recover_cld)); cld->cld_recover = recover_cld; } return 0; + +out_err3: + config_log_put(cld); + +out_err2: + config_log_put(params_cld); + +out_err1: + config_log_put(sptlrpc_cld); + +out_err: + return rc; } DEFINE_MUTEX(llog_process_lock); @@ -344,6 +382,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) { struct config_llog_data *cld; struct config_llog_data *cld_sptlrpc = NULL; + struct config_llog_data *cld_params = NULL; struct config_llog_data *cld_recover = NULL; int rc = 0; @@ -382,11 +421,20 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) spin_lock(&config_list_lock); cld_sptlrpc = cld->cld_sptlrpc; cld->cld_sptlrpc = NULL; + cld_params = cld->cld_params; + cld->cld_params = NULL; spin_unlock(&config_list_lock); if (cld_sptlrpc) config_log_put(cld_sptlrpc); + if (cld_params) { + mutex_lock(&cld_params->cld_lock); + cld_params->cld_stopping = 1; + mutex_unlock(&cld_params->cld_lock); + config_log_put(cld_params); + } + /* drop the ref from the find */ config_log_put(cld); /* drop the start ref */ @@ -1664,7 +1712,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, LCONSOLE_ERROR_MSG(0x13a, "Failed to get MGS log %s and no local copy.\n", cld->cld_logname); - GOTO(out_pop, rc = -ENOTCONN); + GOTO(out_pop, rc = -ENOENT); } CDEBUG(D_MGC, "Failed to get MGS log %s, using local copy for now, will try to update later.\n", @@ -1863,6 +1911,20 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) if (rc) CERROR("Cannot process recover llog %d\n", rc); } + + if (rc == 0 && cld->cld_params != NULL) { + rc = mgc_process_log(obd, cld->cld_params); + if (rc == -ENOENT) { + CDEBUG(D_MGC, + "There is no params config file yet\n"); + rc = 0; + } + /* params log is optional */ + if (rc) + CERROR( + "%s: can't process params llog: rc = %d\n", + obd->obd_name, rc); + } config_log_put(cld); break; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 362ae541b209..27f56c0ab441 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1027,6 +1027,46 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, } EXPORT_SYMBOL(lustre_cfg_rename); +static int process_param2_config(struct lustre_cfg *lcfg) +{ + char *param = lustre_cfg_string(lcfg, 1); + char *upcall = lustre_cfg_string(lcfg, 2); + char *argv[] = { + [0] = "/usr/sbin/lctl", + [1] = "set_param", + [2] = param, + [3] = NULL + }; + struct timeval start; + struct timeval end; + int rc; + + + /* Add upcall processing here. Now only lctl is supported */ + if (strcmp(upcall, LCTL_UPCALL) != 0) { + CERROR("Unsupported upcall %s\n", upcall); + return -EINVAL; + } + + do_gettimeofday(&start); + rc = USERMODEHELPER(argv[0], argv, NULL); + do_gettimeofday(&end); + + if (rc < 0) { + CERROR( + "lctl: error invoking upcall %s %s %s: rc = %d; time %ldus\n", + argv[0], argv[1], argv[2], rc, + cfs_timeval_sub(&end, &start, NULL)); + } else { + CDEBUG(D_HA, "lctl: invoked upcall %s %s %s, time %ldus\n", + argv[0], argv[1], argv[2], + cfs_timeval_sub(&end, &start, NULL)); + rc = 0; + } + + return rc; +} + void lustre_register_quota_process_config(int (*qpc)(struct lustre_cfg *lcfg)) { quota_process_config = qpc; @@ -1142,11 +1182,14 @@ int class_process_config(struct lustre_cfg *lcfg) err = (*quota_process_config)(lcfg); GOTO(out, err); } - /* Fall through */ + break; } + case LCFG_SET_PARAM: { + err = process_param2_config(lcfg); + GOTO(out, 0); + } } - /* Commands that require a device */ obd = class_name2obd(lustre_cfg_string(lcfg, 0)); if (obd == NULL) { From a4c2a3a0a75a7e33f160d404c90daac740d6002a Mon Sep 17 00:00:00 2001 From: JC Lafoucriere Date: Wed, 22 Jan 2014 21:36:18 +0800 Subject: [PATCH 0024/1375] staging/lustre/lustre_user.h: remove obsolete comments This is only part of the original Lustre commit, main part of which changes user space code. And now the comments above struct hsm_copy is no more true. Lustre-change: http://review.whamcloud.com/4737 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2062 Signed-off-by: JC Lafoucriere Signed-off-by: Henri Doreau Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre/lustre_user.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 6b6c0240e824..4d3c25f2033e 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -1158,12 +1158,6 @@ struct hsm_progress { __u32 padding; }; -/** - * Use by copytool during any hsm request they handled. - * This structure is initialized by llapi_hsm_copy_start() - * which is an helper over the ioctl() interface - * Store Lustre, internal use only, data. - */ struct hsm_copy { __u64 hc_data_version; __u16 hc_flags; From 69342b7884d6ea1ec97c0a99fe0524a380783e83 Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Wed, 22 Jan 2014 21:36:19 +0800 Subject: [PATCH 0025/1375] staging/lustre/ptlrpc: flock deadlock detection does not work Flock deadlocks are checked on the first attempt to grant the flock only. If we try again to grant it after its blocking lock is cancelled, we don't check for deadlocks which also may exist. Perform deadlock detection during reprocess Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1715 Lustre-change: http://review.whamcloud.com/3553 Signed-off-by: Andriy Skulysh Reviewed-by: Vitaly Fertman Reviewed-by: Bruce Korb Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 5 ++- .../lustre/lustre/include/lustre_dlm_flags.h | 14 +++++-- .../staging/lustre/lustre/ldlm/ldlm_flock.c | 41 +++++++++++++++++-- .../staging/lustre/lustre/llite/llite_lib.c | 4 +- .../lustre/lustre/obdclass/lprocfs_status.c | 1 + .../staging/lustre/lustre/ptlrpc/wiretest.c | 2 + 6 files changed, 58 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index ac7fb379bf74..05c77c0b2d75 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1304,6 +1304,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); #define OBD_CONNECT_LIGHTWEIGHT 0x1000000000000ULL/* lightweight connection */ #define OBD_CONNECT_SHORTIO 0x2000000000000ULL/* short io */ #define OBD_CONNECT_PINGLESS 0x4000000000000ULL/* pings not required */ +#define OBD_CONNECT_FLOCK_DEAD 0x8000000000000ULL/* flock deadlock detection */ + /* XXX README XXX: * Please DO NOT add flag values here before first ensuring that this same * flag value is not in use on some other branch. Please clear any such @@ -1341,7 +1343,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); OBD_CONNECT_EINPROGRESS | \ OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_UMASK | \ OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK |\ - OBD_CONNECT_PINGLESS | OBD_CONNECT_MAX_EASIZE) + OBD_CONNECT_PINGLESS | OBD_CONNECT_MAX_EASIZE |\ + OBD_CONNECT_FLOCK_DEAD) #define OST_CONNECT_SUPPORTED (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \ OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \ OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h index 75716f17f64b..73fb38ee0a34 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -35,10 +35,10 @@ #ifndef LDLM_ALL_FLAGS_MASK /** l_flags bits marked as "all_flags" bits */ -#define LDLM_FL_ALL_FLAGS_MASK 0x00FFFFFFC08F132FULL +#define LDLM_FL_ALL_FLAGS_MASK 0x00FFFFFFC08F932FULL /** l_flags bits marked as "ast" bits */ -#define LDLM_FL_AST_MASK 0x0000000080000000ULL +#define LDLM_FL_AST_MASK 0x0000000080008000ULL /** l_flags bits marked as "blocked" bits */ #define LDLM_FL_BLOCKED_MASK 0x000000000000000EULL @@ -56,7 +56,7 @@ #define LDLM_FL_LOCAL_ONLY_MASK 0x00FFFFFF00000000ULL /** l_flags bits marked as "on_wire" bits */ -#define LDLM_FL_ON_WIRE_MASK 0x00000000C08F132FULL +#define LDLM_FL_ON_WIRE_MASK 0x00000000C08F932FULL /** extent, mode, or resource changed */ #define LDLM_FL_LOCK_CHANGED 0x0000000000000001ULL // bit 0 @@ -114,6 +114,12 @@ #define ldlm_set_has_intent(_l) LDLM_SET_FLAG(( _l), 1ULL << 12) #define ldlm_clear_has_intent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 12) +/** flock deadlock detected */ +#define LDLM_FL_FLOCK_DEADLOCK 0x0000000000008000ULL /* bit 15 */ +#define ldlm_is_flock_deadlock(_l) LDLM_TEST_FLAG((_l), 1ULL << 15) +#define ldlm_set_flock_deadlock(_l) LDLM_SET_FLAG((_l), 1ULL << 15) +#define ldlm_clear_flock_deadlock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 15) + /** discard (no writeback) on cancel */ #define LDLM_FL_DISCARD_DATA 0x0000000000010000ULL // bit 16 #define ldlm_is_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 16) @@ -390,6 +396,7 @@ static int hf_lustre_ldlm_fl_ast_sent = -1; static int hf_lustre_ldlm_fl_replay = -1; static int hf_lustre_ldlm_fl_intent_only = -1; static int hf_lustre_ldlm_fl_has_intent = -1; +static int hf_lustre_ldlm_fl_flock_deadlock = -1; static int hf_lustre_ldlm_fl_discard_data = -1; static int hf_lustre_ldlm_fl_no_timeout = -1; static int hf_lustre_ldlm_fl_block_nowait = -1; @@ -431,6 +438,7 @@ const value_string lustre_ldlm_flags_vals[] = { {LDLM_FL_REPLAY, "LDLM_FL_REPLAY"}, {LDLM_FL_INTENT_ONLY, "LDLM_FL_INTENT_ONLY"}, {LDLM_FL_HAS_INTENT, "LDLM_FL_HAS_INTENT"}, + {LDLM_FL_FLOCK_DEADLOCK, "LDLM_FL_FLOCK_DEADLOCK"}, {LDLM_FL_DISCARD_DATA, "LDLM_FL_DISCARD_DATA"}, {LDLM_FL_NO_TIMEOUT, "LDLM_FL_NO_TIMEOUT"}, {LDLM_FL_BLOCK_NOWAIT, "LDLM_FL_BLOCK_NOWAIT"}, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index c9aae132f98a..986bf384bff7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -205,6 +205,26 @@ ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock) return 0; } +static void ldlm_flock_cancel_on_deadlock(struct ldlm_lock *lock, + struct list_head *work_list) +{ + CDEBUG(D_INFO, "reprocess deadlock req=%p\n", lock); + + if ((exp_connect_flags(lock->l_export) & + OBD_CONNECT_FLOCK_DEAD) == 0) { + CERROR( + "deadlock found, but client doesn't support flock canceliation\n"); + } else { + LASSERT(lock->l_completion_ast); + LASSERT((lock->l_flags & LDLM_FL_AST_SENT) == 0); + lock->l_flags |= LDLM_FL_AST_SENT | LDLM_FL_CANCEL_ON_BLOCK | + LDLM_FL_FLOCK_DEADLOCK; + ldlm_flock_blocking_unlink(lock); + ldlm_resource_unlink_lock(lock); + ldlm_add_ast_work_item(lock, NULL, work_list); + } +} + /** * Process a granting attempt for flock lock. * Must be called under ns lock held. @@ -272,6 +292,7 @@ reprocess: } } } else { + int reprocess_failed = 0; lockmode_verify(mode); /* This loop determines if there are existing locks @@ -293,8 +314,15 @@ reprocess: if (!ldlm_flocks_overlap(lock, req)) continue; - if (!first_enq) - return LDLM_ITER_CONTINUE; + if (!first_enq) { + reprocess_failed = 1; + if (ldlm_flock_deadlock(req, lock)) { + ldlm_flock_cancel_on_deadlock(req, + work_list); + return LDLM_ITER_CONTINUE; + } + continue; + } if (*flags & LDLM_FL_BLOCK_NOWAIT) { ldlm_flock_destroy(req, mode, *flags); @@ -330,6 +358,8 @@ reprocess: *flags |= LDLM_FL_BLOCK_GRANTED; return LDLM_ITER_STOP; } + if (reprocess_failed) + return LDLM_ITER_CONTINUE; } if (*flags & LDLM_FL_TEST_LOCK) { @@ -646,7 +676,10 @@ granted: /* ldlm_lock_enqueue() has already placed lock on the granted list. */ list_del_init(&lock->l_res_link); - if (flags & LDLM_FL_TEST_LOCK) { + if (lock->l_flags & LDLM_FL_FLOCK_DEADLOCK) { + LDLM_DEBUG(lock, "client-side enqueue deadlock received"); + rc = -EDEADLK; + } else if (flags & LDLM_FL_TEST_LOCK) { /* fcntl(F_GETLK) request */ /* The old mode was saved in getlk->fl_type so that if the mode * in the lock changes we can decref the appropriate refcount.*/ @@ -672,7 +705,7 @@ granted: ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL); } unlock_res_and_lock(lock); - return 0; + return rc; } EXPORT_SYMBOL(ldlm_flock_completion_ast); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 3e4c292769e6..b0b694138869 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -206,7 +206,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, OBD_CONNECT_EINPROGRESS | OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK | - OBD_CONNECT_PINGLESS | OBD_CONNECT_MAX_EASIZE; + OBD_CONNECT_PINGLESS | + OBD_CONNECT_MAX_EASIZE | + OBD_CONNECT_FLOCK_DEAD; if (sbi->ll_flags & LL_SBI_SOM_PREVIEW) data->ocd_connect_flags |= OBD_CONNECT_SOM; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index ec3b605dae6b..6e7d2e561067 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -98,6 +98,7 @@ static const char * const obd_connect_names[] = { "lightweight_conn", "short_io", "pingless", + "flock_deadlock", "unknown", NULL }; diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 3aa445952024..3c8846006a7b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -1152,6 +1152,8 @@ void lustre_assert_wire_constants(void) OBD_CONNECT_SHORTIO); LASSERTF(OBD_CONNECT_PINGLESS == 0x4000000000000ULL, "found 0x%.16llxULL\n", OBD_CONNECT_PINGLESS); + LASSERTF(OBD_CONNECT_FLOCK_DEAD == 0x8000000000000ULL, + "found 0x%.16llxULL\n", OBD_CONNECT_FLOCK_DEAD); LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)OBD_CKSUM_CRC32); LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n", From e92c08092a7f3d2b2c6cccfb8562b64c6e9802e4 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 22 Jan 2014 21:47:32 +0800 Subject: [PATCH 0026/1375] staging/lustre/o2iblnd: fix is_vmalloc_addr build warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I got this building Lustre: drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c: In function ‘kiblnd_kvaddr_to_page’: drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:532:2: warning: passing argument 1 of ‘is_vmalloc_addr’ makes pointer from integer without a cast [enabled by default] Cc: Laura Abbott Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 93648632ba26..6f58ead20393 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -529,7 +529,7 @@ kiblnd_kvaddr_to_page (unsigned long vaddr) { struct page *page; - if (is_vmalloc_addr(vaddr)) { + if (is_vmalloc_addr((void *)vaddr)) { page = vmalloc_to_page ((void *)vaddr); LASSERT (page != NULL); return page; From 82c3fef5682d501d02ccb8b32dcc24ecad7986e6 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 22 Jan 2014 21:47:33 +0800 Subject: [PATCH 0027/1375] staging/lustre/libcfs: remove cfs_curproc_groups_nr no user. Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/curproc.h | 7 ------- .../lustre/lustre/libcfs/linux/linux-curproc.c | 11 ----------- 2 files changed, 18 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index 507d16b9213c..9e5239383828 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -43,13 +43,6 @@ #ifndef __LIBCFS_CURPROC_H__ #define __LIBCFS_CURPROC_H__ -/* - * Portable API to access common characteristics of "current" UNIX process. - * - * Implemented in portals/include/libcfs// - */ -int cfs_curproc_groups_nr(void); - /* * Plus, platform-specific constant * diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index a2ef64c3403d..01370629e14f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -55,16 +55,6 @@ * for Linux kernel. */ -int cfs_curproc_groups_nr(void) -{ - int nr; - - task_lock(current); - nr = current_cred()->group_info->ngroups; - task_unlock(current); - return nr; -} - /* Currently all the CFS_CAP_* defines match CAP_* ones. */ #define cfs_cap_pack(cap) (cap) #define cfs_cap_unpack(cap) (cap) @@ -292,7 +282,6 @@ out: } EXPORT_SYMBOL(cfs_get_environ); -EXPORT_SYMBOL(cfs_curproc_groups_nr); EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); From 3b01cf803112f02b55b574b7df37599fac6fee27 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 22 Jan 2014 21:47:34 +0800 Subject: [PATCH 0028/1375] staging/lustre/libcfs: remove cfs_curproc_cap_unpack no user. Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/curproc.h | 1 - .../staging/lustre/lustre/libcfs/linux/linux-curproc.c | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index 9e5239383828..d12cfb176457 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -84,7 +84,6 @@ void cfs_cap_raise(cfs_cap_t cap); void cfs_cap_lower(cfs_cap_t cap); int cfs_cap_raised(cfs_cap_t cap); cfs_cap_t cfs_curproc_cap_pack(void); -void cfs_curproc_cap_unpack(cfs_cap_t cap); int cfs_capable(cfs_cap_t cap); /* __LIBCFS_CURPROC_H__ */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 01370629e14f..65cb2fa232f5 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -116,15 +116,6 @@ cfs_cap_t cfs_curproc_cap_pack(void) return cap; } -void cfs_curproc_cap_unpack(cfs_cap_t cap) -{ - struct cred *cred; - if ((cred = prepare_creds())) { - cfs_kernel_cap_unpack(&cred->cap_effective, cap); - commit_creds(cred); - } -} - int cfs_capable(cfs_cap_t cap) { return capable(cfs_cap_unpack(cap)); @@ -286,7 +277,6 @@ EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); EXPORT_SYMBOL(cfs_curproc_cap_pack); -EXPORT_SYMBOL(cfs_curproc_cap_unpack); EXPORT_SYMBOL(cfs_capable); /* From 9a28b1881cef46727d7ba81a5d743db2321155b0 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 22 Jan 2014 21:47:35 +0800 Subject: [PATCH 0029/1375] staging/lustre/libcfs: remove cfs_cap_{un}pack Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- .../lustre/libcfs/linux/linux-curproc.c | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 65cb2fa232f5..81a1d0d7755f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -55,15 +55,11 @@ * for Linux kernel. */ -/* Currently all the CFS_CAP_* defines match CAP_* ones. */ -#define cfs_cap_pack(cap) (cap) -#define cfs_cap_unpack(cap) (cap) - void cfs_cap_raise(cfs_cap_t cap) { struct cred *cred; if ((cred = prepare_creds())) { - cap_raise(cred->cap_effective, cfs_cap_unpack(cap)); + cap_raise(cred->cap_effective, cap); commit_creds(cred); } } @@ -72,25 +68,25 @@ void cfs_cap_lower(cfs_cap_t cap) { struct cred *cred; if ((cred = prepare_creds())) { - cap_lower(cred->cap_effective, cfs_cap_unpack(cap)); + cap_lower(cred->cap_effective, cap); commit_creds(cred); } } int cfs_cap_raised(cfs_cap_t cap) { - return cap_raised(current_cap(), cfs_cap_unpack(cap)); + return cap_raised(current_cap(), cap); } void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) { #if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330 - *cap = cfs_cap_pack(kcap); + *cap = kcap; #elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026 - *cap = cfs_cap_pack(kcap[0]); + *cap = kcap[0]; #elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522 /* XXX lost high byte */ - *cap = cfs_cap_pack(kcap.cap[0]); + *cap = kcap.cap[0]; #else #error "need correct _KERNEL_CAPABILITY_VERSION " #endif @@ -99,11 +95,11 @@ void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) void cfs_kernel_cap_unpack(kernel_cap_t *kcap, cfs_cap_t cap) { #if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330 - *kcap = cfs_cap_unpack(cap); + *kcap = cap; #elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026 - (*kcap)[0] = cfs_cap_unpack(cap); + (*kcap)[0] = cap; #elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522 - kcap->cap[0] = cfs_cap_unpack(cap); + kcap->cap[0] = cap; #else #error "need correct _KERNEL_CAPABILITY_VERSION " #endif @@ -118,7 +114,7 @@ cfs_cap_t cfs_curproc_cap_pack(void) int cfs_capable(cfs_cap_t cap) { - return capable(cfs_cap_unpack(cap)); + return capable(cap); } static int cfs_access_process_vm(struct task_struct *tsk, unsigned long addr, From efc9eb02898037b9639c8b5d17feaec2f853cf9c Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 22 Jan 2014 21:47:36 +0800 Subject: [PATCH 0030/1375] staging/lustre/libcfs: remove CAPABILITY_VERSION tests _LINUX_CAPABILITY_VERSION is only for backward compatibility in user space. Kernel code doesn't care about it. Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/libcfs/linux/linux-curproc.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 81a1d0d7755f..8b3af7f2c432 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -80,29 +80,13 @@ int cfs_cap_raised(cfs_cap_t cap) void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) { -#if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330 - *cap = kcap; -#elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026 - *cap = kcap[0]; -#elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522 /* XXX lost high byte */ *cap = kcap.cap[0]; -#else - #error "need correct _KERNEL_CAPABILITY_VERSION " -#endif } void cfs_kernel_cap_unpack(kernel_cap_t *kcap, cfs_cap_t cap) { -#if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330 - *kcap = cap; -#elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026 - (*kcap)[0] = cap; -#elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522 kcap->cap[0] = cap; -#else - #error "need correct _KERNEL_CAPABILITY_VERSION " -#endif } cfs_cap_t cfs_curproc_cap_pack(void) From 2eb90a757e9d953c9e2a8fce530422189992fb1b Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 22 Jan 2014 21:47:37 +0800 Subject: [PATCH 0031/1375] staging/lustre/libcfs: remove cfs_capable Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/curproc.h | 1 - .../lustre/lustre/libcfs/linux/linux-curproc.c | 6 ------ .../lustre/lustre/libcfs/linux/linux-module.c | 4 ++-- drivers/staging/lustre/lustre/llite/dir.c | 8 ++++---- drivers/staging/lustre/lustre/llite/file.c | 10 +++++----- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/llite/xattr.c | 2 +- .../lustre/lustre/obdclass/linux/linux-module.c | 2 +- drivers/staging/lustre/lustre/obdclass/obdo.c | 4 ++-- .../staging/lustre/lustre/obdecho/echo_client.c | 16 ++++++++-------- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- 13 files changed, 28 insertions(+), 35 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index d12cfb176457..8fd47c98fd33 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -84,7 +84,6 @@ void cfs_cap_raise(cfs_cap_t cap); void cfs_cap_lower(cfs_cap_t cap); int cfs_cap_raised(cfs_cap_t cap); cfs_cap_t cfs_curproc_cap_pack(void); -int cfs_capable(cfs_cap_t cap); /* __LIBCFS_CURPROC_H__ */ #endif diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 8b3af7f2c432..6d0bd220d53d 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -96,11 +96,6 @@ cfs_cap_t cfs_curproc_cap_pack(void) return cap; } -int cfs_capable(cfs_cap_t cap) -{ - return capable(cap); -} - static int cfs_access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) { @@ -257,7 +252,6 @@ EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); EXPORT_SYMBOL(cfs_curproc_cap_pack); -EXPORT_SYMBOL(cfs_capable); /* * Local variables: diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 55296a3591d5..e6eae0666f0d 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -150,12 +150,12 @@ static long libcfs_ioctl(struct file *file, /* Handle platform-dependent IOC requests */ switch (cmd) { case IOC_LIBCFS_PANIC: - if (!cfs_capable(CFS_CAP_SYS_BOOT)) + if (!capable(CFS_CAP_SYS_BOOT)) return (-EPERM); panic("debugctl-invoked panic"); return (0); case IOC_LIBCFS_MEMHOG: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; /* go thought */ } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 1b217c8802b0..a6860e895d04 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1085,7 +1085,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) case Q_QUOTAOFF: case Q_SETQUOTA: case Q_SETINFO: - if (!cfs_capable(CFS_CAP_SYS_ADMIN) || + if (!capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) return -EPERM; break; @@ -1094,7 +1094,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) uid_eq(current_euid(), make_kuid(&init_user_ns, id))) || (type == GRPQUOTA && !in_egroup_p(make_kgid(&init_user_ns, id)))) && - (!cfs_capable(CFS_CAP_SYS_ADMIN) || + (!capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT)) return -EPERM; break; @@ -1602,7 +1602,7 @@ out_rmdir: struct obd_quotactl *oqctl; int error = 0; - if (!cfs_capable(CFS_CAP_SYS_ADMIN) || + if (!capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) return -EPERM; @@ -1626,7 +1626,7 @@ out_rmdir: case OBD_IOC_POLL_QUOTACHECK: { struct if_quotacheck *check; - if (!cfs_capable(CFS_CAP_SYS_ADMIN) || + if (!capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) return -EPERM; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index c12821aedc2f..19125d5c991a 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1340,7 +1340,7 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) struct ll_recreate_obj ucreat; struct ost_id oi; - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user(&ucreat, (struct ll_recreate_obj *)arg, @@ -1358,7 +1358,7 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) struct ost_id oi; obd_count ost_idx; - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user(&fid, (struct lu_fid *)arg, sizeof(fid))) @@ -1497,7 +1497,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, sizeof(struct lov_user_ost_data); int rc; - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; OBD_ALLOC_LARGE(lump, lum_size); @@ -1747,7 +1747,7 @@ int ll_fid2path(struct inode *inode, void *arg) struct getinfo_fid2path *gfout, *gfin; int outsize, rc; - if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) && + if (!capable(CFS_CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) return -EPERM; @@ -2093,7 +2093,7 @@ static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss) /* Non-root users are forbidden to set or clear flags which are * NOT defined in HSM_USER_MASK. */ if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) && - !cfs_capable(CFS_CAP_SYS_ADMIN)) + !capable(CFS_CAP_SYS_ADMIN)) return -EPERM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b0b694138869..85c01e155680 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1403,7 +1403,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ if (attr->ia_valid & TIMES_SET_FLAGS) { if ((!uid_eq(current_fsuid(), inode->i_uid)) && - !cfs_capable(CFS_CAP_FOWNER)) + !capable(CFS_CAP_FOWNER)) return -EPERM; } diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 3a7d03c12dd9..af83580c6d48 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -95,7 +95,7 @@ int xattr_type_filter(struct ll_sb_info *sbi, int xattr_type) if (xattr_type == XATTR_USER_T && !(sbi->ll_flags & LL_SBI_USER_XATTR)) return -EOPNOTSUPP; - if (xattr_type == XATTR_TRUSTED_T && !cfs_capable(CFS_CAP_SYS_ADMIN)) + if (xattr_type == XATTR_TRUSTED_T && !capable(CFS_CAP_SYS_ADMIN)) return -EPERM; if (xattr_type == XATTR_OTHER_T) return -EOPNOTSUPP; diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 121a856d5052..ba20776ebfa1 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -184,7 +184,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, int err = 0; /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ - if (!cfs_capable(CFS_CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) + if (!capable(CFS_CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) return err = -EACCES; if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ return err = -ENOTTY; diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 70997648a4f3..e9cd6db43eeb 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -233,7 +233,7 @@ void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid) oa->o_mode = attr->ia_mode; oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE; if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) && - !cfs_capable(CFS_CAP_FSETID)) + !capable(CFS_CAP_FSETID)) oa->o_mode &= ~S_ISGID; } if (ia_valid & ATTR_UID) { @@ -282,7 +282,7 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid) attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT); attr->ia_valid |= ATTR_MODE; if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) && - !cfs_capable(CFS_CAP_FSETID)) + !capable(CFS_CAP_FSETID)) attr->ia_mode &= ~S_ISGID; } if (valid & OBD_MD_FLUID) { diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 9b2dea292363..268a202c21e5 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -2764,7 +2764,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, switch (cmd) { case OBD_IOC_CREATE: /* may create echo object */ - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); rc = echo_create_object(env, ed, 1, oa, data->ioc_pbuf1, @@ -2778,7 +2778,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, int dirlen; __u64 id; - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); count = data->ioc_count; @@ -2806,7 +2806,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, __u64 seq; int max_count; - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); cl_env = cl_env_get(&refcheck); @@ -2838,7 +2838,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); } case OBD_IOC_DESTROY: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); rc = echo_get_object(&eco, ed, oa); @@ -2863,7 +2863,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case OBD_IOC_SETATTR: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); rc = echo_get_object(&eco, ed, oa); @@ -2878,7 +2878,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case OBD_IOC_BRW_WRITE: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); rw = OBD_BRW_WRITE; @@ -2897,7 +2897,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case ECHO_IOC_SET_STRIPE: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); if (data->ioc_pbuf1 == NULL) { /* unset */ @@ -2914,7 +2914,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO (out, rc); case ECHO_IOC_ENQUEUE: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) + if (!capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); rc = echo_client_enqueue(exp, oa, diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index be4511e78c04..b92a02efad43 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2146,7 +2146,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, oap->oap_obj_off = offset; LASSERT(!(offset & ~CFS_PAGE_MASK)); - if (!client_is_remote(exp) && cfs_capable(CFS_CAP_SYS_RESOURCE)) + if (!client_is_remote(exp) && capable(CFS_CAP_SYS_RESOURCE)) oap->oap_brw_flags = OBD_BRW_NOQUOTA; INIT_LIST_HEAD(&oap->oap_pending_item); @@ -2186,7 +2186,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* Set the OBD_BRW_SRVLOCK before the page is queued. */ brw_flags |= ops->ops_srvlock ? OBD_BRW_SRVLOCK : 0; if (!client_is_remote(osc_export(osc)) && - cfs_capable(CFS_CAP_SYS_RESOURCE)) { + capable(CFS_CAP_SYS_RESOURCE)) { brw_flags |= OBD_BRW_NOQUOTA; cmd |= OBD_BRW_NOQUOTA; } diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 681d60a7d5ef..777ae24bbfff 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -297,7 +297,7 @@ static int osc_io_commit_write(const struct lu_env *env, */ osc_page_touch(env, cl2osc_page(slice), to); if (!client_is_remote(osc_export(obj)) && - cfs_capable(CFS_CAP_SYS_RESOURCE)) + capable(CFS_CAP_SYS_RESOURCE)) oap->oap_brw_flags |= OBD_BRW_NOQUOTA; if (oio->oi_lockless) diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 4909e486dc5c..96cb6e2b9c4e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -561,7 +561,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags; if (!client_is_remote(osc_export(obj)) && - cfs_capable(CFS_CAP_SYS_RESOURCE)) { + capable(CFS_CAP_SYS_RESOURCE)) { oap->oap_brw_flags |= OBD_BRW_NOQUOTA; oap->oap_cmd |= OBD_BRW_NOQUOTA; } From de636b389d2eeb06cb91dbffb699e8dcf142910b Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 30 Jan 2014 12:48:51 -0500 Subject: [PATCH 0032/1375] staging: lustre: remove unnecessary 'magic' from lustre_pack_request This probably made more sense when the code supported multiple protocol versions, but now it's just obfuscation. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 464479c0f00b..c319f74b04f6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -244,15 +244,7 @@ int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count, LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body)); /* only use new format, we don't need to be compatible with 1.4 */ - magic = LUSTRE_MSG_MAGIC_V2; - - switch (magic) { - case LUSTRE_MSG_MAGIC_V2: - return lustre_pack_request_v2(req, count, lens, bufs); - default: - LASSERTF(0, "incorrect message magic: %08x\n", magic); - return -EINVAL; - } + return lustre_pack_request_v2(req, count, lens, bufs); } EXPORT_SYMBOL(lustre_pack_request); From 930cef9a69eb86a74c134eaa30742f0893c2b499 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Feb 2014 00:30:35 +0900 Subject: [PATCH 0033/1375] staging: lustre: Fix typo in client.c This patch fixed spelling typo found in client.c Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index d90efe408414..eb33bb7c86ae 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -62,7 +62,7 @@ void ptlrpc_init_client(int req_portal, int rep_portal, char *name, EXPORT_SYMBOL(ptlrpc_init_client); /** - * Return PortalRPC connection for remore uud \a uuid + * Return PortalRPC connection for remote uud \a uuid */ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid) { @@ -127,7 +127,7 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw, * Prepare bulk descriptor for specified outgoing request \a req that * can fit \a npages * pages. \a type is bulk type. \a portal is where * the bulk to be sent. Used on client-side. - * Returns pointer to newly allocatrd initialized bulk descriptor or NULL on + * Returns pointer to newly allocated initialized bulk descriptor or NULL on * error. */ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, @@ -631,7 +631,7 @@ int ptlrpc_request_pack(struct ptlrpc_request *request, /* For some old 1.8 clients (< 1.8.7), they will LASSERT the size of * ptlrpc_body sent from server equal to local ptlrpc_body size, so we - * have to send old ptlrpc_body to keep interoprability with these + * have to send old ptlrpc_body to keep interoperability with these * clients. * * Only three kinds of server->client RPCs so far: @@ -639,7 +639,7 @@ int ptlrpc_request_pack(struct ptlrpc_request *request, * - LDLM_CP_CALLBACK * - LDLM_GL_CALLBACK * - * XXX This should be removed whenever we drop the interoprability with + * XXX This should be removed whenever we drop the interoperability with * the these old clients. */ if (opcode == LDLM_BL_CALLBACK || opcode == LDLM_CP_CALLBACK || @@ -686,7 +686,7 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp, /** * Helper function for creating a request. - * Calls __ptlrpc_request_alloc to allocate new request sturcture and inits + * Calls __ptlrpc_request_alloc to allocate new request structure and inits * buffer structures according to capsule template \a format. * Returns allocated request structure pointer or NULL on error. */ @@ -743,7 +743,7 @@ void ptlrpc_request_free(struct ptlrpc_request *request) EXPORT_SYMBOL(ptlrpc_request_free); /** - * Allocate new request for operatione \a opcode and immediatelly pack it for + * Allocate new request for operation \a opcode and immediately pack it for * network transfer. * Only used for simple requests like OBD_PING where the only important * part of the request is operation itself. @@ -768,7 +768,7 @@ struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp, EXPORT_SYMBOL(ptlrpc_request_alloc_pack); /** - * Prepare request (fetched from pool \a poolif not NULL) on import \a imp + * Prepare request (fetched from pool \a pool if not NULL) on import \a imp * for operation \a opcode. Request would contain \a count buffers. * Sizes of buffers are described in array \a lengths and buffers themselves * are provided by a pointer \a bufs. @@ -1073,7 +1073,7 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, } /** - * Decide if the eror message regarding provided request \a req + * Decide if the error message regarding provided request \a req * should be printed to the console or not. * Makes it's decision on request status and other properties. * Returns 1 to print error on the system console or 0 if not. @@ -1159,7 +1159,7 @@ static void ptlrpc_save_versions(struct ptlrpc_request *req) /** * Callback function called when client receives RPC reply for \a req. * Returns 0 on success or error code. - * The return alue would be assigned to req->rq_status by the caller + * The return value would be assigned to req->rq_status by the caller * as request processing status. * This function also decides if the request needs to be saved for later replay. */ @@ -2031,7 +2031,7 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) EXPORT_SYMBOL(ptlrpc_set_next_timeout); /** - * Send all unset request from the set and then wait untill all + * Send all unset request from the set and then wait until all * requests in the set complete (either get a reply, timeout, get an * error or otherwise be interrupted). * Returns 0 on success or error code otherwise. @@ -2156,7 +2156,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) EXPORT_SYMBOL(ptlrpc_set_wait); /** - * Helper fuction for request freeing. + * Helper function for request freeing. * Called when request count reached zero and request needs to be freed. * Removes request from all sorts of sending/replay lists it might be on, * frees network buffers if any are present. @@ -2223,7 +2223,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked); /** * Drop one request reference. Must be called with import imp_lock held. - * When reference count drops to zero, reuqest is freed. + * When reference count drops to zero, request is freed. */ void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request) { @@ -2236,7 +2236,7 @@ EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock); * Helper function * Drops one reference count for request \a request. * \a locked set indicates that caller holds import imp_lock. - * Frees the request whe reference count reaches zero. + * Frees the request when reference count reaches zero. */ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) { @@ -2364,7 +2364,7 @@ EXPORT_SYMBOL(ptlrpc_unregister_reply); * Iterates through replay_list on import and prunes * all requests have transno smaller than last_committed for the * import and don't have rq_replay set. - * Since requests are sorted in transno order, stops when meetign first + * Since requests are sorted in transno order, stops when meeting first * transno bigger than last_committed. * caller must hold imp->imp_lock */ @@ -2585,7 +2585,7 @@ struct ptlrpc_replay_async_args { /** * Callback used for replayed requests reply processing. - * In case of succesful reply calls registeresd request replay callback. + * In case of successful reply calls registered request replay callback. * In case of error restart replay process. */ static int ptlrpc_replay_interpret(const struct lu_env *env, @@ -2834,7 +2834,7 @@ void ptlrpc_init_xid(void) ptlrpc_last_xid = (__u64)now << 20; } - /* Need to always be aligned to a power-of-two for mutli-bulk BRW */ + /* Always need to be aligned to a power-of-two for multi-bulk BRW */ CLASSERT((PTLRPC_BULK_OPS_COUNT & (PTLRPC_BULK_OPS_COUNT - 1)) == 0); ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK; } From 369e5c9a5ee0049b930d169394b8470f093fb4d9 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Feb 2014 00:30:36 +0900 Subject: [PATCH 0034/1375] staging: lustre: Fix typo in service.c This patch fixed spelling typo founx in service.c Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/service.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 590fa8df8b7f..cc18a23f077a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -177,7 +177,7 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) /** * Part of Rep-Ack logic. - * Puts a lock and its mode into reply state assotiated to request reply. + * Puts a lock and its mode into reply state associated to request reply. */ void ptlrpc_save_lock(struct ptlrpc_request *req, @@ -252,7 +252,7 @@ struct rs_batch { static struct ptlrpc_hr_service ptlrpc_hr; /** - * maximum mumber of replies scheduled in one batch + * maximum number of replies scheduled in one batch */ #define MAX_SCHEDULED 256 @@ -612,7 +612,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, INIT_LIST_HEAD(&svcpt->scp_hist_reqs); INIT_LIST_HEAD(&svcpt->scp_hist_rqbds); - /* acitve requests and hp requests */ + /* active requests and hp requests */ spin_lock_init(&svcpt->scp_req_lock); /* reply states */ @@ -1982,7 +1982,7 @@ put_conn: do_gettimeofday(&work_end); timediff = cfs_timeval_sub(&work_end, &work_start, NULL); CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc " - "%s:%s+%d:%d:x"LPU64":%s:%d Request procesed in " + "%s:%s+%d:%d:x"LPU64":%s:%d Request processed in " "%ldus (%ldus total) trans "LPU64" rc %d/%d\n", current_comm(), (request->rq_export ? @@ -2736,7 +2736,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) spin_lock(&svcpt->scp_lock); --svcpt->scp_nthrs_starting; if (thread_is_stopping(thread)) { - /* this ptlrpc_thread is being hanled + /* this ptlrpc_thread is being handled * by ptlrpc_svcpt_stop_threads now */ thread_add_flags(thread, SVC_STOPPED); From 0c2bc7584a4c301d759fa762b806b9e45d80846d Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Feb 2014 00:30:37 +0900 Subject: [PATCH 0035/1375] staging: lustre: Fix typo in sec.c This patch fixed spelling typos in sec.c Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 962b31d163de..9145dd25023b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -779,7 +779,7 @@ again: * e.g. ptlrpc_abort_inflight(); */ if (!cli_ctx_is_refreshed(ctx)) { - /* timed out or interruptted */ + /* timed out or interrupted */ req_off_ctx_list(req, ctx); LASSERT(rc != 0); @@ -805,7 +805,7 @@ void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode) LASSERT(req->rq_cli_ctx->cc_sec); LASSERT(req->rq_bulk_read == 0 || req->rq_bulk_write == 0); - /* special security flags accoding to opcode */ + /* special security flags according to opcode */ switch (opcode) { case OST_READ: case MDS_READPAGE: @@ -1218,7 +1218,7 @@ static void sec_cop_destroy_sec(struct ptlrpc_sec *sec) LASSERT_ATOMIC_ZERO(&sec->ps_nctx); LASSERT(policy->sp_cops->destroy_sec); - CDEBUG(D_SEC, "%s@%p: being destroied\n", sec->ps_policy->sp_name, sec); + CDEBUG(D_SEC, "%s@%p: being destroyed\n", sec->ps_policy->sp_name, sec); policy->sp_cops->destroy_sec(sec); sptlrpc_policy_put(policy); @@ -1264,7 +1264,7 @@ void sptlrpc_sec_put(struct ptlrpc_sec *sec) EXPORT_SYMBOL(sptlrpc_sec_put); /* - * policy module is responsible for taking refrence of import + * policy module is responsible for taking reference of import */ static struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, @@ -1419,7 +1419,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, sp = imp->imp_obd->u.cli.cl_sp_me; } else { - /* reverse import, determine flavor from incoming reqeust */ + /* reverse import, determine flavor from incoming request */ sf = *flvr; if (sf.sf_rpc != SPTLRPC_FLVR_NULL) @@ -2057,7 +2057,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) /* * if it's not null flavor (which means embedded packing msg), - * reset the swab mask for the comming inner msg unpacking. + * reset the swab mask for the coming inner msg unpacking. */ if (SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) != SPTLRPC_POLICY_NULL) req->rq_req_swab_mask = 0; @@ -2108,7 +2108,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) /** * Used by ptlrpc server, to perform transformation upon reply message. * - * \post req->rq_reply_off is set to approriate server-controlled reply offset. + * \post req->rq_reply_off is set to appropriate server-controlled reply offset. * \post req->rq_repmsg and req->rq_reply_state->rs_msg becomes inaccessible. */ int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req) From 08c4c90dc2cfb719b787b39fb9cab9880b60d779 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Feb 2014 00:30:38 +0900 Subject: [PATCH 0036/1375] staging: lustre: Fix typo in sec_gss.c This patch fixed spelling typo in comments wihtin sec_gss.c Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c index 8ce6271a5daa..42ee33186c53 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c @@ -382,7 +382,7 @@ void gss_cli_ctx_uptodate(struct gss_cli_ctx *gctx) /* At this point this ctx might have been marked as dead by * someone else, in which case nobody will make further use * of it. we don't care, and mark it UPTODATE will help - * destroying server side context when it be destroied. */ + * destroying server side context when it be destroyed. */ set_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags); if (sec_is_reverse(ctx->cc_sec)) { @@ -676,7 +676,7 @@ redo: * lead to the sequence number fall behind the window on server and * be dropped. also applies to gss_cli_ctx_seal(). * - * Note: null mode dosen't check sequence number. */ + * Note: null mode doesn't check sequence number. */ if (svc != SPTLRPC_SVC_NULL && atomic_read(&gctx->gc_seq) - seq > GSS_SEQ_REPACK_THRESHOLD) { int behind = atomic_read(&gctx->gc_seq) - seq; @@ -1882,7 +1882,7 @@ int gss_svc_sign(struct ptlrpc_request *req, LASSERT(rs->rs_msg == lustre_msg_buf(rs->rs_repbuf, 1, 0)); - /* embedded lustre_msg might have been shrinked */ + /* embedded lustre_msg might have been shrunk */ if (req->rq_replen != rs->rs_repbuf->lm_buflens[1]) lustre_shrink_msg(rs->rs_repbuf, 1, req->rq_replen, 1); @@ -2596,7 +2596,7 @@ static int gss_svc_seal(struct ptlrpc_request *req, int msglen, rc; /* get clear data length. note embedded lustre_msg might - * have been shrinked */ + * have been shrunk */ if (req->rq_replen != lustre_msg_buflen(rs->rs_repbuf, 0)) msglen = lustre_shrink_msg(rs->rs_repbuf, 0, req->rq_replen, 1); else @@ -2765,7 +2765,7 @@ int gss_copy_rvc_cli_ctx(struct ptlrpc_cli_ctx *cli_ctx, * replay. * * each reverse root ctx will record its latest sequence number on its - * buddy svcctx before be destroied, so here we continue use it. + * buddy svcctx before be destroyed, so here we continue use it. */ atomic_set(&cli_gctx->gc_seq, svc_gctx->gsc_rvs_seq); @@ -2836,7 +2836,7 @@ int __init sptlrpc_gss_init(void) if (rc) goto out_svc_upcall; - /* register policy after all other stuff be intialized, because it + /* register policy after all other stuff be initialized, because it * might be in used immediately after the registration. */ rc = gss_init_keyring(); From fb4b81fea5038736f5109897c5f52d08b2036e2d Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Feb 2014 00:30:39 +0900 Subject: [PATCH 0037/1375] staging: lustre: Fix typo in lustre/ptlrpc/gss This patch fixed spelling typo in comments within lustre/ptlrpc/gss. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c index 55247af3910e..c279edf5b2a5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -336,7 +336,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (rc) { /* If any _real_ denial be made, we expect server return * -EACCES reply or return success but indicate gss error - * inside reply messsage. All other errors are treated as + * inside reply message. All other errors are treated as * timeout, caller might try the negotiation repeatedly, * leave recovery decisions to general ptlrpc layer. * diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c index d43a13c69669..4642bbfb9273 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c @@ -1176,7 +1176,7 @@ int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) /* * called with key semaphore write locked. it means we can operate - * on the context without fear of loosing refcount. + * on the context without fear of losing refcount. */ static int gss_kt_update(struct key *key, const void *data, size_t datalen) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c index c624518c181a..7a1ff4fecbe3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c @@ -85,7 +85,7 @@ static void gss_sec_pipe_upcall_fini(struct gss_sec *gsec) } /**************************************** - * internel context helpers * + * internal context helpers * ****************************************/ static @@ -652,7 +652,7 @@ __u32 mech_name2idx(const char *name) /* pipefs dentries for each mechanisms */ static struct dentry *de_pipes[MECH_MAX] = { NULL, }; -/* all upcall messgaes linked here */ +/* all upcall messages linked here */ static struct list_head upcall_lists[MECH_MAX]; /* and protected by this */ static spinlock_t upcall_locks[MECH_MAX]; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c index 5b5365b4629f..8d25a70585dd 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -586,7 +586,7 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen) goto out; /* currently the expiry time passed down from user-space - * is invalid, here we retrive it from mech. */ + * is invalid, here we retrieve it from mech. */ if (lgss_inquire_context(rsci.ctx.gsc_mechctx, &ctx_expiry)) { CERROR("unable to get expire time, drop it\n"); goto out; @@ -1067,7 +1067,7 @@ int __init gss_init_svc_upcall(void) * the init upcall channel, otherwise there's big chance that the first * upcall issued before the channel be opened thus nfsv4 cache code will * drop the request direclty, thus lead to unnecessary recovery time. - * here we wait at miximum 1.5 seconds. */ + * here we wait at maximum 1.5 seconds. */ for (i = 0; i < 6; i++) { if (atomic_read(&rsi_cache.readers) > 0) break; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c index 42ee33186c53..383601cdd4e6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c @@ -1215,7 +1215,7 @@ int gss_cli_ctx_fini_common(struct ptlrpc_sec *sec, /* * remove UPTODATE flag of reverse ctx thus we won't send fini rpc, * this is to avoid potential problems of client side reverse svc ctx - * be mis-destroyed in various recovery senarios. anyway client can + * be mis-destroyed in various recovery scenarios. anyway client can * manage its reverse ctx well by associating it with its buddy ctx. */ if (sec_is_reverse(sec)) From b6da17f31934372c982bda87258a297bc6ee8950 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Feb 2014 00:30:40 +0900 Subject: [PATCH 0038/1375] staging: lustre: Fix typo in lustre/ptlrpc This patch fixed spelling typo in lustre/ptlrpc. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/layout.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index f66cfea87acf..6ea0a491cfb3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -545,7 +545,7 @@ int ptlrpc_ni_init(void) * different depending on... */ /* kernel LNet calls our master callback when there are new event, * because we are guaranteed to get every event via callback, - * so we just set EQ size to 0 to avoid overhread of serializing + * so we just set EQ size to 0 to avoid overhead of serializing * enqueue/dequeue operations in LNet. */ rc = LNetEQAlloc(0, ptlrpc_master_callback, &ptlrpc_eq_h); if (rc == 0) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index f465547eb95e..82db0ed60652 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1042,7 +1042,7 @@ finish: if ((ocd->ocd_cksum_types & cksum_types_supported_client()) == 0) { LCONSOLE_WARN("The negotiation of the checksum " - "alogrithm to use with server %s " + "algorithm to use with server %s " "failed (%x/%x), disabling " "checksums\n", obd2cli_tgt(imp->imp_obd), @@ -1260,7 +1260,7 @@ static int ptlrpc_invalidate_import_thread(void *data) /** * This is the state machine for client-side recovery on import. * - * Typicaly we have two possibly paths. If we came to server and it is not + * Typically we have two possibly paths. If we came to server and it is not * in recovery, we just enter IMP_EVICTED state, invalidate our import * state and reconnect from scratch. * If we came to server that is in recovery, we enter IMP_REPLAY import state. diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index dfcb410fe485..9b8f691cbeb7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -2154,7 +2154,7 @@ EXPORT_SYMBOL(req_capsule_server_sized_swab_get); * request (if the caller is executing on the server-side) or reply (if the * caller is executing on the client-side). * - * This function convienient for use is code that could be executed on the + * This function convenient for use is code that could be executed on the * client and server alike. */ const void *req_capsule_other_get(struct req_capsule *pill, diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 1be978609c59..58f1c8bf25b0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -616,7 +616,7 @@ out: } /** - * The longest valid command string is the maxium policy name size, plus the + * The longest valid command string is the maximum policy name size, plus the * length of the " reg" substring */ #define LPROCFS_NRS_WR_MAX_CMD (NRS_POL_NAME_MAX + sizeof(" reg") - 1) @@ -1184,7 +1184,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer, } tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count)); /* Kludge code(deadlock situation): the lprocfs lock has been held - * since the client is evicted by writting client's + * 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 * the proc entries under the being destroyed export{}, so I have diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 3c6bf23415f9..1e94597eaea5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -349,7 +349,7 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) /** * Send request reply from request \a req reply buffer. * \a flags defines reply types - * Returns 0 on sucess or error code + * Returns 0 on success or error code */ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) { @@ -389,7 +389,7 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) * ptlrpc_body in reply buffer to ptlrpc_body_v2, otherwise, the * reply buffer on client will be overflow. * - * XXX Remove this whenver we drop the interoprability with such client. + * XXX Remove this whenever we drop the interoprability with such client. */ req->rq_replen = lustre_shrink_msg(req->rq_repmsg, 0, sizeof(struct ptlrpc_body_v2), 1); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 0abcd6d82273..bcba1c8e8693 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -1322,7 +1322,7 @@ EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister); * Setup NRS heads on all service partitions of service \a svc, and register * all compatible policies on those NRS heads. * - * To be called from withing ptl + * To be called from within ptl * \param[in] svc the service to setup * * \retval -ve error, the calling logic should eventually call @@ -1736,7 +1736,7 @@ fail: } /** - * Removes all policy desciptors from nrs_core::nrs_policies, and frees the + * Removes all policy descriptors from nrs_core::nrs_policies, and frees the * policy descriptors. * * Since all PTLRPC services are stopped at this point, there are no more diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index c319f74b04f6..45c0b84621e4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -123,7 +123,7 @@ int lustre_msg_early_size(void) * with the old client (< 2.3) which doesn't have pb_jobid * in the ptlrpc_body. * - * XXX Remove this whenever we dorp interoprability with such + * XXX Remove this whenever we drop interoprability with such * client. */ __u32 pblen = sizeof(struct ptlrpc_body_v2); @@ -1537,7 +1537,7 @@ void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid) __u32 opc = lustre_msg_get_opc(msg); struct ptlrpc_body *pb; - /* Don't set jobid for ldlm ast RPCs, they've been shrinked. + /* Don't set jobid for ldlm ast RPCs, they've been shrunk. * See the comment in ptlrpc_request_pack(). */ if (!opc || opc == LDLM_BL_CALLBACK || opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK) diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 2d26fd543d46..ca734ce079c1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -229,7 +229,7 @@ void ptlrpcd_add_req(struct ptlrpc_request *req, pdl_policy_t policy, int idx) spin_unlock(&req->rq_lock); l_wait_event(req->rq_set_waitq, (req->rq_set == NULL), &lwi); } else if (req->rq_set) { - /* If we have a vaid "rq_set", just reuse it to avoid double + /* If we have a valid "rq_set", just reuse it to avoid double * linked. */ LASSERT(req->rq_phase == RQ_PHASE_NEW); LASSERT(req->rq_send_state == LUSTRE_IMP_REPLAY); @@ -471,7 +471,7 @@ static int ptlrpcd(void *arg) * be better. But it breaks former data transfer policy. * * So we shouldn't be blind for avoiding the data transfer. We make some - * compromise: divide the ptlrpcd threds pool into two parts. One part is + * compromise: divide the ptlrpcd threads pool into two parts. One part is * for bound mode, each ptlrpcd thread in this part is bound to some CPU * core. The other part is for free mode, all the ptlrpcd threads in the * part can be scheduled on any CPU core. We specify some partnership diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 316103ab7c3c..f65955d40d92 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -113,7 +113,7 @@ static struct ptlrpc_enc_page_pool { unsigned long epp_st_missings; /* # of cache missing */ unsigned long epp_st_lowfree; /* lowest free pages reached */ unsigned int epp_st_max_wqlen; /* highest waitqueue length */ - cfs_time_t epp_st_max_wait; /* in jeffies */ + cfs_time_t epp_st_max_wait; /* in jiffies */ /* * pointers to pools */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 6cc3f23c27cc..bf56120abfaf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -255,7 +255,7 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset) EXPORT_SYMBOL(sptlrpc_rule_set_free); /* - * return 0 if the rule set could accomodate one more rule. + * return 0 if the rule set could accommodate one more rule. */ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index cc18a23f077a..192adec5382a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -752,7 +752,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, spin_lock_init(&service->srv_lock); service->srv_name = conf->psc_name; service->srv_watchdog_factor = conf->psc_watchdog_factor; - INIT_LIST_HEAD(&service->srv_list); /* for safty of cleanup */ + INIT_LIST_HEAD(&service->srv_list); /* for safety of cleanup */ /* buffer configuration */ service->srv_nbuf_per_group = test_req_buffer_pressure ? From b20d44174779b75a04ee7772d0c26b58344fefeb Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 13 Jan 2014 21:09:39 -0800 Subject: [PATCH 0039/1375] staging: ced1401: Fix dev_ messages Add a missing newline to each message. Standardize style to "%s: ...", __func__. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ced1401/ced_ioc.c | 151 ++++++++++++------------ drivers/staging/ced1401/usb1401.c | 188 +++++++++++++++--------------- 2 files changed, 171 insertions(+), 168 deletions(-) diff --git a/drivers/staging/ced1401/ced_ioc.c b/drivers/staging/ced1401/ced_ioc.c index bf532b1bd345..573a283fb12c 100644 --- a/drivers/staging/ced1401/ced_ioc.c +++ b/drivers/staging/ced1401/ced_ioc.c @@ -38,8 +38,8 @@ ****************************************************************************/ static void FlushOutBuff(DEVICE_EXTENSION *pdx) { - dev_dbg(&pdx->interface->dev, "%s currentState=%d", __func__, - pdx->sCurrentState); + dev_dbg(&pdx->interface->dev, "%s: currentState=%d\n", + __func__, pdx->sCurrentState); if (pdx->sCurrentState == U14ERR_TIME) /* Do nothing if hardware in trouble */ return; /* Kill off any pending I/O */ @@ -59,8 +59,8 @@ static void FlushOutBuff(DEVICE_EXTENSION *pdx) ****************************************************************************/ static void FlushInBuff(DEVICE_EXTENSION *pdx) { - dev_dbg(&pdx->interface->dev, "%s currentState=%d", __func__, - pdx->sCurrentState); + dev_dbg(&pdx->interface->dev, "%s: currentState=%d\n", + __func__, pdx->sCurrentState); if (pdx->sCurrentState == U14ERR_TIME) /* Do nothing if hardware in trouble */ return; /* Kill off any pending I/O */ @@ -118,8 +118,8 @@ int SendString(DEVICE_EXTENSION *pdx, const char __user *pData, mutex_lock(&pdx->io_mutex); /* Protect disconnect from new i/o */ if (n > 0) { /* do nothing if nowt to do! */ - dev_dbg(&pdx->interface->dev, "%s n=%d>%s<", __func__, n, - buffer); + dev_dbg(&pdx->interface->dev, "%s: n=%d>%s<\n", + __func__, n, buffer); iReturn = PutChars(pdx, buffer, n); } @@ -139,7 +139,7 @@ int SendChar(DEVICE_EXTENSION *pdx, char c) int iReturn; mutex_lock(&pdx->io_mutex); /* Protect disconnect from new i/o */ iReturn = PutChars(pdx, &c, 1); - dev_dbg(&pdx->interface->dev, "SendChar >%c< (0x%02x)", c, c); + dev_dbg(&pdx->interface->dev, "SendChar >%c< (0x%02x)\n", c, c); Allowi(pdx); /* Make sure char reads are running */ mutex_unlock(&pdx->io_mutex); return iReturn; @@ -174,7 +174,7 @@ int SendChar(DEVICE_EXTENSION *pdx, char c) int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, __u32 *error) { int nGot; - dev_dbg(&pdx->interface->dev, "Get1401State() entry"); + dev_dbg(&pdx->interface->dev, "%s: entry\n", __func__); *state = 0xFFFFFFFF; /* Start off with invalid state */ nGot = usb_control_msg(pdx->udev, usb_rcvctrlpipe(pdx->udev, 0), @@ -182,15 +182,15 @@ int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, __u32 *error) pdx->statBuf, sizeof(pdx->statBuf), HZ); if (nGot != sizeof(pdx->statBuf)) { dev_err(&pdx->interface->dev, - "Get1401State() FAILED, return code %d", nGot); + "%s: FAILED, return code %d\n", __func__, nGot); pdx->sCurrentState = U14ERR_TIME; /* Indicate that things are very wrong indeed */ *state = 0; /* Force status values to a known state */ *error = 0; } else { int nDevice; dev_dbg(&pdx->interface->dev, - "Get1401State() Success, state: 0x%x, 0x%x", - pdx->statBuf[0], pdx->statBuf[1]); + "%s: Success, state: 0x%x, 0x%x\n", + __func__, pdx->statBuf[0], pdx->statBuf[1]); *state = pdx->statBuf[0]; /* Return the state values to the calling code */ *error = pdx->statBuf[1]; @@ -220,8 +220,8 @@ int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, __u32 *error) ****************************************************************************/ int ReadWrite_Cancel(DEVICE_EXTENSION *pdx) { - dev_dbg(&pdx->interface->dev, "ReadWrite_Cancel entry %d", - pdx->bStagedUrbPending); + dev_dbg(&pdx->interface->dev, "%s: entry %d\n", + __func__, pdx->bStagedUrbPending); #ifdef NOT_WRITTEN_YET int ntStatus = STATUS_SUCCESS; bool bResult = false; @@ -231,7 +231,7 @@ int ReadWrite_Cancel(DEVICE_EXTENSION *pdx) if (pdx->bStagedUrbPending) { /* anything to be cancelled? May need more... */ dev_info(&pdx->interface - dev, - "ReadWrite_Cancel about to cancel Urb"); + "ReadWrite_Cancel about to cancel Urb\n"); /* Clear the staging done flag */ /* KeClearEvent(&pdx->StagingDoneEvent); */ USB_ASSERT(pdx->pStagedIrp != NULL); @@ -244,14 +244,14 @@ int ReadWrite_Cancel(DEVICE_EXTENSION *pdx) LARGE_INTEGER timeout; timeout.QuadPart = -10000000; /* Use a timeout of 1 second */ dev_info(&pdx->interface - dev, - "ReadWrite_Cancel about to wait till done"); + "%s: about to wait till done\n", __func__); ntStatus = KeWaitForSingleObject(&pdx->StagingDoneEvent, Executive, KernelMode, FALSE, &timeout); } else { dev_info(&pdx->interface - dev, - "ReadWrite_Cancel, cancellation failed"); + "%s: cancellation failed\n", __func__); ntStatus = U14ERR_FAIL; } USB_KdPrint(DBGLVL_DEFAULT, @@ -260,7 +260,7 @@ int ReadWrite_Cancel(DEVICE_EXTENSION *pdx) } else spin_unlock_irq(&pdx->stagedLock); - dev_info(&pdx->interface - dev, "ReadWrite_Cancel done"); + dev_info(&pdx->interface - dev, "%s: done\n", __func__); return ntStatus; #else return U14ERR_NOERROR; @@ -304,7 +304,7 @@ static int InSelfTest(DEVICE_EXTENSION *pdx, unsigned int *pState) bool Is1401(DEVICE_EXTENSION *pdx) { int iReturn; - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); ced_draw_down(pdx); /* wait for, then kill outstanding Urbs */ FlushInBuff(pdx); /* Clear out input buffer & pipe */ @@ -368,7 +368,7 @@ bool QuickCheck(DEVICE_EXTENSION *pdx, bool bTestBuff, bool bCanReset) (pdx->sCurrentState >= U14ERR_STD)); /* No 1401 errors stored */ dev_dbg(&pdx->interface->dev, - "%s DMAFlag:%d, state:%d, force:%d, testBuff:%d, short:%d", + "%s: DMAFlag:%d, state:%d, force:%d, testBuff:%d, short:%d\n", __func__, pdx->dwDMAFlag, pdx->sCurrentState, pdx->bForceReset, bTestBuff, bShortTest); @@ -376,13 +376,13 @@ bool QuickCheck(DEVICE_EXTENSION *pdx, bool bTestBuff, bool bCanReset) (pdx->dwNumInput || pdx->dwNumOutput)) { /* ...characters were in the buffer? */ bShortTest = false; /* Then do the full test */ dev_dbg(&pdx->interface->dev, - "%s will reset as buffers not empty", __func__); + "%s: will reset as buffers not empty\n", __func__); } if (bShortTest || !bCanReset) { /* Still OK to try the short test? */ /* Always test if no reset - we want state update */ unsigned int state, error; - dev_dbg(&pdx->interface->dev, "%s->Get1401State", __func__); + dev_dbg(&pdx->interface->dev, "%s: Get1401State\n", __func__); if (Get1401State(pdx, &state, &error) == U14ERR_NOERROR) { /* Check on the 1401 state */ if ((state & 0xFF) == 0) /* If call worked, check the status value */ bRet = true; /* If that was zero, all is OK, no reset needed */ @@ -390,7 +390,7 @@ bool QuickCheck(DEVICE_EXTENSION *pdx, bool bTestBuff, bool bCanReset) } if (!bRet && bCanReset) { /* If all not OK, then */ - dev_info(&pdx->interface->dev, "%s->Is1401 %d %d %d %d", + dev_info(&pdx->interface->dev, "%s: Is1401 %d %d %d %d\n", __func__, bShortTest, pdx->sCurrentState, bTestBuff, pdx->bForceReset); bRet = Is1401(pdx); /* do full test */ @@ -407,7 +407,8 @@ bool QuickCheck(DEVICE_EXTENSION *pdx, bool bTestBuff, bool bCanReset) int Reset1401(DEVICE_EXTENSION *pdx) { mutex_lock(&pdx->io_mutex); /* Protect disconnect from new i/o */ - dev_dbg(&pdx->interface->dev, "ABout to call QuickCheck"); + dev_dbg(&pdx->interface->dev, "%s: About to call QuickCheck\n", + __func__); QuickCheck(pdx, true, true); /* Check 1401, reset if not OK */ mutex_unlock(&pdx->io_mutex); return U14ERR_NOERROR; @@ -423,7 +424,7 @@ int GetChar(DEVICE_EXTENSION *pdx) int iReturn = U14ERR_NOIN; /* assume we will get nothing */ mutex_lock(&pdx->io_mutex); /* Protect disconnect from new i/o */ - dev_dbg(&pdx->interface->dev, "GetChar"); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); Allowi(pdx); /* Make sure char reads are running */ SendChars(pdx); /* and send any buffered chars */ @@ -497,8 +498,8 @@ int GetString(DEVICE_EXTENSION *pdx, char __user *pUser, int n) pdx->dwNumInput -= nGot; spin_unlock_irq(&pdx->charInLock); - dev_dbg(&pdx->interface->dev, - "GetString read %d characters >%s<", nGot, buffer); + dev_dbg(&pdx->interface->dev, "%s: read %d characters >%s<\n", + __func__, nGot, buffer); if (copy_to_user(pUser, buffer, nCopyToUser)) iReturn = -EFAULT; else @@ -555,7 +556,7 @@ int LineCount(DEVICE_EXTENSION *pdx) } spin_unlock_irq(&pdx->charInLock); - dev_dbg(&pdx->interface->dev, "LineCount returned %d", iReturn); + dev_dbg(&pdx->interface->dev, "%s: returned %d\n", __func__, iReturn); mutex_unlock(&pdx->io_mutex); /* Protect disconnect from new i/o */ return iReturn; } @@ -571,7 +572,7 @@ int GetOutBufSpace(DEVICE_EXTENSION *pdx) mutex_lock(&pdx->io_mutex); /* Protect disconnect from new i/o */ SendChars(pdx); /* send any buffered chars */ iReturn = (int)(OUTBUF_SZ - pdx->dwNumOutput); /* no lock needed for single read */ - dev_dbg(&pdx->interface->dev, "OutBufSpace %d", iReturn); + dev_dbg(&pdx->interface->dev, "%s: %d\n", __func__, iReturn); mutex_unlock(&pdx->io_mutex); /* Protect disconnect from new i/o */ return iReturn; } @@ -589,7 +590,7 @@ int ClearArea(DEVICE_EXTENSION *pdx, int nArea) if ((nArea < 0) || (nArea >= MAX_TRANSAREAS)) { iReturn = U14ERR_BADAREA; - dev_err(&pdx->interface->dev, "%s Attempt to clear area %d", + dev_err(&pdx->interface->dev, "%s: Attempt to clear area %d\n", __func__, nArea); } else { TRANSAREA *pTA = &pdx->rTransDef[nArea]; /* to save typing */ @@ -602,14 +603,14 @@ int ClearArea(DEVICE_EXTENSION *pdx, int nArea) int nPages = 0; /* and number of pages */ int np; - dev_dbg(&pdx->interface->dev, "%s area %d", __func__, - nArea); + dev_dbg(&pdx->interface->dev, "%s: area %d\n", + __func__, nArea); spin_lock_irq(&pdx->stagedLock); if ((pdx->StagedId == nArea) && (pdx->dwDMAFlag > MODE_CHAR)) { iReturn = U14ERR_UNLOCKFAIL; /* cannot delete as in use */ dev_err(&pdx->interface->dev, - "%s call on area %d while active", + "%s: call on area %d while active\n", __func__, nArea); } else { pPages = pTA->pPages; /* save page address list */ @@ -633,7 +634,7 @@ int ClearArea(DEVICE_EXTENSION *pdx, int nArea) /* Now we must undo the pinning down of the pages. We will assume the worst and mark */ /* all the pages as dirty. Don't be tempted to move this up above as you must not be */ /* holding a spin lock to do this stuff as it is not atomic. */ - dev_dbg(&pdx->interface->dev, "%s nPages=%d", + dev_dbg(&pdx->interface->dev, "%s: nPages=%d\n", __func__, nPages); for (np = 0; np < nPages; ++np) { @@ -645,7 +646,7 @@ int ClearArea(DEVICE_EXTENSION *pdx, int nArea) kfree(pPages); dev_dbg(&pdx->interface->dev, - "%s kfree(pPages) done", __func__); + "%s: kfree(pPages) done\n", __func__); } } } @@ -687,12 +688,12 @@ static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf, iReturn = U14ERR_NOMEMORY; goto error; } - dev_dbg(&pdx->interface->dev, "%s %p, length=%06x, circular %d", + dev_dbg(&pdx->interface->dev, "%s: %p, length=%06x, circular %d\n", __func__, puBuf, dwLength, bCircular); /* To pin down user pages we must first acquire the mapping semaphore. */ nPages = get_user_pages_fast(ulStart, len, 1, pPages); - dev_dbg(&pdx->interface->dev, "%s nPages = %d", __func__, nPages); + dev_dbg(&pdx->interface->dev, "%s: nPages = %d\n", __func__, nPages); if (nPages > 0) { /* if we succeeded */ /* If you are tempted to use page_address (form LDD3), forget it. You MUST use */ @@ -744,8 +745,8 @@ int SetTransfer(DEVICE_EXTENSION *pdx, TRANSFERDESC __user *pTD) return -EFAULT; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s area:%d, size:%08x", __func__, - td.wAreaNum, td.dwLength); + dev_dbg(&pdx->interface->dev, "%s: area:%d, size:%08x\n", + __func__, td.wAreaNum, td.dwLength); /* The strange cast is done so that we don't get warnings in 32-bit linux about the size of the */ /* pointer. The pointer is always passed as a 64-bit object so that we don't have problems using */ /* a 32-bit program on a 64-bit system. unsigned long is 64-bits on a 64-bit system. */ @@ -922,7 +923,7 @@ int GetTransfer(DEVICE_EXTENSION *pdx, TGET_TX_BLOCK __user *pTX) ****************************************************************************/ int KillIO1401(DEVICE_EXTENSION *pdx) { - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); mutex_lock(&pdx->io_mutex); FlushOutBuff(pdx); FlushInBuff(pdx); @@ -938,7 +939,7 @@ int KillIO1401(DEVICE_EXTENSION *pdx) int BlkTransState(DEVICE_EXTENSION *pdx) { int iReturn = pdx->dwDMAFlag != MODE_CHAR; - dev_dbg(&pdx->interface->dev, "%s = %d", __func__, iReturn); + dev_dbg(&pdx->interface->dev, "%s: %d\n", __func__, iReturn); return iReturn; } @@ -956,7 +957,7 @@ int StateOf1401(DEVICE_EXTENSION *pdx) iReturn = pdx->sCurrentState; mutex_unlock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s = %d", __func__, iReturn); + dev_dbg(&pdx->interface->dev, "%s: %d\n", __func__, iReturn); return iReturn; } @@ -971,7 +972,7 @@ int StartSelfTest(DEVICE_EXTENSION *pdx) { int nGot; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); ced_draw_down(pdx); /* wait for, then kill outstanding Urbs */ FlushInBuff(pdx); /* Clear out input buffer & pipe */ @@ -987,7 +988,7 @@ int StartSelfTest(DEVICE_EXTENSION *pdx) mutex_unlock(&pdx->io_mutex); if (nGot < 0) - dev_err(&pdx->interface->dev, "%s err=%d", __func__, nGot); + dev_err(&pdx->interface->dev, "%s: err=%d\n", __func__, nGot); return nGot < 0 ? U14ERR_FAIL : U14ERR_NOERROR; } @@ -1005,7 +1006,7 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST) mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); iReturn = Get1401State(pdx, &state, &error); if (iReturn == U14ERR_NOERROR) /* Only accept zero if it happens twice */ iReturn = Get1401State(pdx, &state, &error); @@ -1013,8 +1014,8 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST) if (iReturn != U14ERR_NOERROR) { /* Self-test can cause comms errors */ /* so we assume still testing */ dev_err(&pdx->interface->dev, - "%s Get1401State=%d, assuming still testing", __func__, - iReturn); + "%s: Get1401State=%d, assuming still testing\n", + __func__, iReturn); state = 0x80; /* Force still-testing, no error */ error = 0; iReturn = U14ERR_NOERROR; @@ -1022,7 +1023,7 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST) if ((state == -1) && (error == -1)) { /* If Get1401State had problems */ dev_err(&pdx->interface->dev, - "%s Get1401State failed, assuming still testing", + "%s: Get1401State failed, assuming still testing\n", __func__); state = 0x80; /* Force still-testing, no error */ error = 0; @@ -1033,21 +1034,21 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST) gst.code = (state & 0x00FF0000) >> 16; /* read the error code */ gst.x = error & 0x0000FFFF; /* Error data X */ gst.y = (error & 0xFFFF0000) >> 16; /* and data Y */ - dev_dbg(&pdx->interface->dev, "Self-test error code %d", - gst.code); + dev_dbg(&pdx->interface->dev, + "Self-test error code %d\n", gst.code); } else { /* No error, check for timeout */ unsigned long ulNow = jiffies; /* get current time */ if (time_after(ulNow, pdx->ulSelfTestTime)) { gst.code = -2; /* Flag the timeout */ dev_dbg(&pdx->interface->dev, - "Self-test timed-out"); + "Self-test timed-out\n"); } else dev_dbg(&pdx->interface->dev, - "Self-test on-going"); + "Self-test on-going\n"); } } else { gst.code = -1; /* Flag the test is done */ - dev_dbg(&pdx->interface->dev, "Self-test done"); + dev_dbg(&pdx->interface->dev, "Self-test done\n"); } if (gst.code < 0) { /* If we have a problem or finished */ @@ -1074,7 +1075,7 @@ int TypeOf1401(DEVICE_EXTENSION *pdx) { int iReturn = TYPEUNKNOWN; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); switch (pdx->s1401Type) { case TYPE1401: @@ -1092,7 +1093,7 @@ int TypeOf1401(DEVICE_EXTENSION *pdx) else /* for up-coming 1401 designs */ iReturn = TYPEUNKNOWN; /* Don't know or not there */ } - dev_dbg(&pdx->interface->dev, "%s %d", __func__, iReturn); + dev_dbg(&pdx->interface->dev, "%s %d\n", __func__, iReturn); mutex_unlock(&pdx->io_mutex); return iReturn; @@ -1107,7 +1108,7 @@ int TransferFlags(DEVICE_EXTENSION *pdx) { int iReturn = U14TF_MULTIA | U14TF_DIAG | /* we always have multiple DMA area */ U14TF_NOTIFY | U14TF_CIRCTH; /* diagnostics, notify and circular */ - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); mutex_lock(&pdx->io_mutex); if (pdx->bIsUSB2) /* Set flag for USB2 if appropriate */ iReturn |= U14TF_USB2; @@ -1125,15 +1126,15 @@ static int DbgCmd1401(DEVICE_EXTENSION *pdx, unsigned char cmd, unsigned int data) { int iReturn; - dev_dbg(&pdx->interface->dev, "%s entry", __func__); + dev_dbg(&pdx->interface->dev, "%s: entry\n", __func__); iReturn = usb_control_msg(pdx->udev, usb_sndctrlpipe(pdx->udev, 0), cmd, (H_TO_D | VENDOR | DEVREQ), (unsigned short)data, (unsigned short)(data >> 16), NULL, 0, HZ); /* allow 1 second timeout */ if (iReturn < 0) - dev_err(&pdx->interface->dev, "%s fail code=%d", __func__, - iReturn); + dev_err(&pdx->interface->dev, "%s: fail code=%d\n", + __func__, iReturn); return iReturn; } @@ -1152,7 +1153,7 @@ int DbgPeek(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB) return -EFAULT; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s @ %08x", __func__, db.iAddr); + dev_dbg(&pdx->interface->dev, "%s: @ %08x\n", __func__, db.iAddr); iReturn = DbgCmd1401(pdx, DB_SETADD, db.iAddr); if (iReturn == U14ERR_NOERROR) @@ -1181,7 +1182,7 @@ int DbgPoke(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB) return -EFAULT; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s @ %08x", __func__, db.iAddr); + dev_dbg(&pdx->interface->dev, "%s: @ %08x\n", __func__, db.iAddr); iReturn = DbgCmd1401(pdx, DB_SETADD, db.iAddr); if (iReturn == U14ERR_NOERROR) @@ -1210,7 +1211,7 @@ int DbgRampData(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB) return -EFAULT; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s @ %08x", __func__, db.iAddr); + dev_dbg(&pdx->interface->dev, "%s: @ %08x\n", __func__, db.iAddr); iReturn = DbgCmd1401(pdx, DB_SETADD, db.iAddr); if (iReturn == U14ERR_NOERROR) @@ -1242,7 +1243,7 @@ int DbgRampAddr(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB) return -EFAULT; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); iReturn = DbgCmd1401(pdx, DB_SETDEF, db.iDefault); if (iReturn == U14ERR_NOERROR) @@ -1270,7 +1271,7 @@ int DbgGetData(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB) memset(&db, 0, sizeof(db)); /* fill returned block with 0s */ mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); /* Read back the last peeked value from the 1401. */ iReturn = usb_control_msg(pdx->udev, usb_rcvctrlpipe(pdx->udev, 0), @@ -1282,8 +1283,8 @@ int DbgGetData(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB) else iReturn = U14ERR_NOERROR; } else - dev_err(&pdx->interface->dev, "%s failed, code %d", __func__, - iReturn); + dev_err(&pdx->interface->dev, "%s: failed, code %d\n", + __func__, iReturn); mutex_unlock(&pdx->io_mutex); @@ -1302,7 +1303,7 @@ int DbgStopLoop(DEVICE_EXTENSION *pdx) unsigned int uState, uErr; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); iReturn = Get1401State(pdx, &uState, &uErr); mutex_unlock(&pdx->io_mutex); @@ -1327,8 +1328,8 @@ int SetCircular(DEVICE_EXTENSION *pdx, TRANSFERDESC __user *pTD) return -EFAULT; mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s area:%d, size:%08x", __func__, - td.wAreaNum, td.dwLength); + dev_dbg(&pdx->interface->dev, "%s: area:%d, size:%08x\n", + __func__, td.wAreaNum, td.dwLength); bToHost = td.eSize != 0; /* this is used as the tohost flag */ /* The strange cast is done so that we don't get warnings in 32-bit linux about the size of the */ @@ -1353,7 +1354,7 @@ int GetCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB) unsigned int nArea; TCIRCBLOCK cb; - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); if (copy_from_user(&cb, pCB, sizeof(cb))) return -EFAULT; @@ -1374,7 +1375,7 @@ int GetCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB) cb.dwOffset = pArea->aBlocks[0].dwOffset; cb.dwSize = pArea->aBlocks[0].dwSize; dev_dbg(&pdx->interface->dev, - "%s return block 0: %d bytes at %d", + "%s: return block 0: %d bytes at %d\n", __func__, cb.dwSize, cb.dwOffset); } } else @@ -1402,7 +1403,7 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB) unsigned int nArea, uStart, uSize; TCIRCBLOCK cb; - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); if (copy_from_user(&cb, pCB, sizeof(cb))) return -EFAULT; @@ -1437,7 +1438,7 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB) } dev_dbg(&pdx->interface->dev, - "%s free %d bytes at %d, return %d bytes at %d, wait=%d", + "%s: free %d bytes at %d, return %d bytes at %d, wait=%d\n", __func__, uSize, uStart, pArea->aBlocks[0].dwSize, pArea->aBlocks[0].dwOffset, @@ -1453,13 +1454,13 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB) bWaiting = pdx->bXFerWaiting; if (bWaiting && pdx->bStagedUrbPending) { dev_err(&pdx->interface->dev, - "%s ERROR: waiting xfer and staged Urb pending!", + "%s: ERROR: waiting xfer and staged Urb pending!\n", __func__); bWaiting = false; } } else { dev_err(&pdx->interface->dev, - "%s ERROR: freeing %d bytes at %d, block 0 is %d bytes at %d", + "%s: ERROR: freeing %d bytes at %d, block 0 is %d bytes at %d\n", __func__, uSize, uStart, pArea->aBlocks[0].dwSize, pArea->aBlocks[0].dwOffset); @@ -1475,7 +1476,7 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB) pdx->rDMAInfo.dwSize); if (RWMStat != U14ERR_NOERROR) dev_err(&pdx->interface->dev, - "%s rw setup failed %d", + "%s: rw setup failed %d\n", __func__, RWMStat); } } else diff --git a/drivers/staging/ced1401/usb1401.c b/drivers/staging/ced1401/usb1401.c index efc310ca789e..f441e33660fe 100644 --- a/drivers/staging/ced1401/usb1401.c +++ b/drivers/staging/ced1401/usb1401.c @@ -166,7 +166,7 @@ static int ced_open(struct inode *inode, struct file *file) goto exit; } - dev_dbg(&interface->dev, "%s got pdx", __func__); + dev_dbg(&interface->dev, "%s: got pdx\n", __func__); /* increment our usage count for the device */ kref_get(&pdx->kref); @@ -184,7 +184,7 @@ static int ced_open(struct inode *inode, struct file *file) goto exit; } } else { /* uncomment this block if you want exclusive open */ - dev_err(&interface->dev, "%s fail: already open", __func__); + dev_err(&interface->dev, "%s: fail: already open\n", __func__); retval = -EBUSY; pdx->open_count--; mutex_unlock(&pdx->io_mutex); @@ -207,7 +207,7 @@ static int ced_release(struct inode *inode, struct file *file) if (pdx == NULL) return -ENODEV; - dev_dbg(&pdx->interface->dev, "%s called", __func__); + dev_dbg(&pdx->interface->dev, "%s: called\n", __func__); mutex_lock(&pdx->io_mutex); if (!--pdx->open_count && pdx->interface) /* Allow autosuspend */ usb_autopm_put_interface(pdx->interface); @@ -224,12 +224,12 @@ static int ced_flush(struct file *file, fl_owner_t id) if (pdx == NULL) return -ENODEV; - dev_dbg(&pdx->interface->dev, "%s char in pend=%d", __func__, - pdx->bReadCharsPending); + dev_dbg(&pdx->interface->dev, "%s: char in pend=%d\n", + __func__, pdx->bReadCharsPending); /* wait for io to stop */ mutex_lock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s got io_mutex", __func__); + dev_dbg(&pdx->interface->dev, "%s: got io_mutex\n", __func__); ced_draw_down(pdx); /* read out errors, leave subsequent opens a clean slate */ @@ -239,7 +239,7 @@ static int ced_flush(struct file *file, fl_owner_t id) spin_unlock_irq(&pdx->err_lock); mutex_unlock(&pdx->io_mutex); - dev_dbg(&pdx->interface->dev, "%s exit reached", __func__); + dev_dbg(&pdx->interface->dev, "%s: exit reached\n", __func__); return res; } @@ -270,7 +270,7 @@ static void ced_writechar_callback(struct urb *pUrb) (pUrb->status == -ENOENT || pUrb->status == -ECONNRESET || pUrb->status == -ESHUTDOWN)) { dev_err(&pdx->interface->dev, - "%s - nonzero write bulk status received: %d", + "%s: nonzero write bulk status received: %d\n", __func__, pUrb->status); } @@ -287,10 +287,10 @@ static void ced_writechar_callback(struct urb *pUrb) pdx->bSendCharsPending = false; /* Allow other threads again */ spin_unlock(&pdx->charOutLock); /* already at irq level */ dev_dbg(&pdx->interface->dev, - "%s - char out done, 0 chars sent", __func__); + "%s: char out done, 0 chars sent\n", __func__); } else { dev_dbg(&pdx->interface->dev, - "%s - char out done, %d chars sent", __func__, nGot); + "%s: char out done, %d chars sent\n", __func__, nGot); spin_lock(&pdx->charOutLock); /* already at irq level */ pdx->dwNumOutput -= nGot; /* Now adjust the char send buffer */ pdx->dwOutBuffGet += nGot; /* to match what we did */ @@ -315,15 +315,15 @@ static void ced_writechar_callback(struct urb *pUrb) URB_NO_TRANSFER_DMA_MAP; usb_anchor_urb(pdx->pUrbCharOut, &pdx->submitted); /* in case we need to kill it */ iReturn = usb_submit_urb(pdx->pUrbCharOut, GFP_ATOMIC); - dev_dbg(&pdx->interface->dev, "%s n=%d>%s<", __func__, - dwCount, pDat); + dev_dbg(&pdx->interface->dev, "%s: n=%d>%s<\n", + __func__, dwCount, pDat); spin_lock(&pdx->charOutLock); /* grab lock for errors */ if (iReturn) { pdx->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ pdx->bSendCharsPending = false; /* Allow other threads again */ usb_unanchor_urb(pdx->pUrbCharOut); dev_err(&pdx->interface->dev, - "%s usb_submit_urb() returned %d", + "%s: usb_submit_urb() returned %d\n", __func__, iReturn); } } else @@ -350,8 +350,8 @@ int SendChars(DEVICE_EXTENSION *pdx) pdx->bSendCharsPending = true; /* Set flag to lock out other threads */ dev_dbg(&pdx->interface->dev, - "Send %d chars to 1401, EP0 flag %d\n", dwCount, - pdx->nPipes == 3); + "Send %d chars to 1401, EP0 flag %d\n", + dwCount, pdx->nPipes == 3); /* If we have only 3 end points we must send the characters to the 1401 using EP0. */ if (pdx->nPipes == 3) { /* For EP0 character transmissions to the 1401, we have to hang about until they */ @@ -375,11 +375,11 @@ int SendChars(DEVICE_EXTENSION *pdx) if (nSent <= 0) { iReturn = nSent ? nSent : -ETIMEDOUT; /* if 0 chars says we timed out */ dev_err(&pdx->interface->dev, - "Send %d chars by EP0 failed: %d", + "Send %d chars by EP0 failed: %d\n", n, iReturn); } else { dev_dbg(&pdx->interface->dev, - "Sent %d chars by EP0", n); + "Sent %d chars by EP0\n", n); count -= nSent; index += nSent; } @@ -416,9 +416,9 @@ int SendChars(DEVICE_EXTENSION *pdx) } } else if (pdx->bSendCharsPending && (pdx->dwNumOutput > 0)) dev_dbg(&pdx->interface->dev, - "SendChars bSendCharsPending:true"); + "%s: bSendCharsPending:true\n", __func__); - dev_dbg(&pdx->interface->dev, "SendChars exit code: %d", iReturn); + dev_dbg(&pdx->interface->dev, "%s: exit code: %d\n", __func__, iReturn); spin_unlock_irq(&pdx->charOutLock); /* Now let go of the spinlock */ return iReturn; } @@ -446,7 +446,7 @@ static void CopyUserSpace(DEVICE_EXTENSION *pdx, int n) pdx->StagedDone + pdx->StagedOffset + pArea->dwBaseOffset; char *pCoherBuf = pdx->pCoherStagedIO; /* coherent buffer */ if (!pArea->bUsed) { - dev_err(&pdx->interface->dev, "%s area %d unused", + dev_err(&pdx->interface->dev, "%s: area %d unused\n", __func__, nArea); return; } @@ -474,21 +474,21 @@ static void CopyUserSpace(DEVICE_EXTENSION *pdx, int n) n -= uiXfer; } else { dev_err(&pdx->interface->dev, - "%s did not map page %d", + "%s: did not map page %d\n", __func__, nPage); return; } } else { dev_err(&pdx->interface->dev, - "%s exceeded pages %d", __func__, - nPage); + "%s: exceeded pages %d\n", + __func__, nPage); return; } } } else - dev_err(&pdx->interface->dev, "%s bad area %d", __func__, - nArea); + dev_err(&pdx->interface->dev, "%s: bad area %d\n", + __func__, nArea); } /* Forward declarations for stuff used circularly */ @@ -513,11 +513,11 @@ static void staged_callback(struct urb *pUrb) (pUrb->status == -ENOENT || pUrb->status == -ECONNRESET || pUrb->status == -ESHUTDOWN)) { dev_err(&pdx->interface->dev, - "%s - nonzero write bulk status received: %d", + "%s: nonzero write bulk status received: %d\n", __func__, pUrb->status); } else dev_info(&pdx->interface->dev, - "%s - staged xfer cancelled", __func__); + "%s: staged xfer cancelled\n", __func__); spin_lock(&pdx->err_lock); pdx->errors = pUrb->status; @@ -525,26 +525,26 @@ static void staged_callback(struct urb *pUrb) nGot = 0; /* and tidy up again if so */ bCancel = true; } else { - dev_dbg(&pdx->interface->dev, "%s %d chars xferred", __func__, - nGot); + dev_dbg(&pdx->interface->dev, "%s: %d chars xferred\n", + __func__, nGot); if (pdx->StagedRead) /* if reading, save to user space */ CopyUserSpace(pdx, nGot); /* copy from buffer to user */ if (nGot == 0) - dev_dbg(&pdx->interface->dev, "%s ZLP", __func__); + dev_dbg(&pdx->interface->dev, "%s: ZLP\n", __func__); } /* Update the transfer length based on the TransferBufferLength value in the URB */ pdx->StagedDone += nGot; - dev_dbg(&pdx->interface->dev, "%s, done %d bytes of %d", __func__, - pdx->StagedDone, pdx->StagedLength); + dev_dbg(&pdx->interface->dev, "%s: done %d bytes of %d\n", + __func__, pdx->StagedDone, pdx->StagedLength); if ((pdx->StagedDone == pdx->StagedLength) || /* If no more to do */ (bCancel)) { /* or this IRP was cancelled */ TRANSAREA *pArea = &pdx->rTransDef[pdx->StagedId]; /* Transfer area info */ dev_dbg(&pdx->interface->dev, - "%s transfer done, bytes %d, cancel %d", __func__, - pdx->StagedDone, bCancel); + "%s: transfer done, bytes %d, cancel %d\n", + __func__, pdx->StagedDone, bCancel); /* Here is where we sort out what to do with this transfer if using a circular buffer. We have */ /* a completed transfer that can be assumed to fit into the transfer area. We should be able to */ @@ -559,7 +559,7 @@ static void staged_callback(struct urb *pUrb) pArea->aBlocks[1].dwSize += pdx->StagedLength; dev_dbg(&pdx->interface->dev, - "RWM_Complete, circ block 1 now %d bytes at %d", + "RWM_Complete, circ block 1 now %d bytes at %d\n", pArea->aBlocks[1].dwSize, pArea->aBlocks[1].dwOffset); } else { @@ -569,7 +569,7 @@ static void staged_callback(struct urb *pUrb) pArea->aBlocks[1].dwSize = pdx->StagedLength; dev_err(&pdx->interface->dev, - "%s ERROR, circ block 1 re-started %d bytes at %d", + "%s: ERROR, circ block 1 re-started %d bytes at %d\n", __func__, pArea->aBlocks[1].dwSize, pArea->aBlocks[1].dwOffset); @@ -582,7 +582,7 @@ static void staged_callback(struct urb *pUrb) pArea->aBlocks[0].dwSize)) { pArea->aBlocks[0].dwSize += pdx->StagedLength; /* Just add this transfer in */ dev_dbg(&pdx->interface->dev, - "RWM_Complete, circ block 0 now %d bytes at %d", + "RWM_Complete, circ block 0 now %d bytes at %d\n", pArea->aBlocks[0]. dwSize, pArea->aBlocks[0]. @@ -593,7 +593,7 @@ static void staged_callback(struct urb *pUrb) pArea->aBlocks[1].dwSize = pdx->StagedLength; dev_dbg(&pdx->interface->dev, - "RWM_Complete, circ block 1 started %d bytes at %d", + "RWM_Complete, circ block 1 started %d bytes at %d\n", pArea->aBlocks[1]. dwSize, pArea->aBlocks[1]. @@ -605,7 +605,7 @@ static void staged_callback(struct urb *pUrb) pArea->aBlocks[0].dwSize = pdx->StagedLength; dev_dbg(&pdx->interface->dev, - "RWM_Complete, circ block 0 started %d bytes at %d", + "RWM_Complete, circ block 0 started %d bytes at %d\n", pArea->aBlocks[0].dwSize, pArea->aBlocks[0].dwOffset); } @@ -614,7 +614,7 @@ static void staged_callback(struct urb *pUrb) if (!bCancel) { /* Don't generate an event if cancelled */ dev_dbg(&pdx->interface->dev, - "RWM_Complete, bCircular %d, bToHost %d, eStart %d, eSize %d", + "RWM_Complete, bCircular %d, bToHost %d, eStart %d, eSize %d\n", pArea->bCircular, pArea->bEventToHost, pArea->dwEventSt, pArea->dwEventSz); if ((pArea->dwEventSz) && /* Set a user-mode event... */ @@ -641,7 +641,7 @@ static void staged_callback(struct urb *pUrb) if (iWakeUp) { dev_dbg(&pdx->interface->dev, - "About to set event to notify app"); + "About to set event to notify app\n"); wake_up_interruptible(&pArea->wqEvent); /* wake up waiting processes */ ++pArea->iWakeUp; /* increment wakeup count */ } @@ -655,7 +655,7 @@ static void staged_callback(struct urb *pUrb) if (pdx->bXFerWaiting) { /* Got a block xfer waiting? */ int iReturn; dev_info(&pdx->interface->dev, - "*** RWM_Complete *** pending transfer will now be set up!!!"); + "*** RWM_Complete *** pending transfer will now be set up!!!\n"); iReturn = ReadWriteMem(pdx, !pdx->rDMAInfo.bOutWard, pdx->rDMAInfo.wIdent, @@ -664,7 +664,7 @@ static void staged_callback(struct urb *pUrb) if (iReturn) dev_err(&pdx->interface->dev, - "RWM_Complete rw setup failed %d", + "RWM_Complete rw setup failed %d\n", iReturn); } } @@ -685,7 +685,7 @@ static void staged_callback(struct urb *pUrb) /* not be upset by char input during DMA... sigh. Needs sorting out. */ if (bRestartCharInput) /* may be out of date, but... */ Allowi(pdx); /* ...Allowi tests a lock too. */ - dev_dbg(&pdx->interface->dev, "%s done", __func__); + dev_dbg(&pdx->interface->dev, "%s: done\n", __func__); } /**************************************************************************** @@ -707,7 +707,7 @@ static int StageChunk(DEVICE_EXTENSION *pdx) return U14ERR_FAIL; if (!CanAcceptIoRequests(pdx)) { /* got sudden remove? */ - dev_info(&pdx->interface->dev, "%s sudden remove, giving up", + dev_info(&pdx->interface->dev, "%s: sudden remove, giving up\n", __func__); return U14ERR_FAIL; /* could do with a better error */ } @@ -731,11 +731,11 @@ static int StageChunk(DEVICE_EXTENSION *pdx) if (iReturn) { usb_unanchor_urb(pdx->pStagedUrb); /* kill it */ pdx->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ - dev_err(&pdx->interface->dev, "%s submit urb failed, code %d", + dev_err(&pdx->interface->dev, "%s: submit urb failed, code %d\n", __func__, iReturn); } else pdx->bStagedUrbPending = true; /* Set the flag for staged URB pending */ - dev_dbg(&pdx->interface->dev, "%s done so far:%d, this size:%d", + dev_dbg(&pdx->interface->dev, "%s: done so far:%d, this size:%d\n", __func__, pdx->StagedDone, ChunkSize); return iReturn; @@ -764,28 +764,28 @@ int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent, TRANSAREA *pArea = &pdx->rTransDef[wIdent]; /* Transfer area info */ if (!CanAcceptIoRequests(pdx)) { /* Are we in a state to accept new requests? */ - dev_err(&pdx->interface->dev, "%s can't accept requests", + dev_err(&pdx->interface->dev, "%s: can't accept requests\n", __func__); return U14ERR_FAIL; } dev_dbg(&pdx->interface->dev, - "%s xfer %d bytes to %s, offset %d, area %d", __func__, dwLen, - Read ? "host" : "1401", dwOffs, wIdent); + "%s: xfer %d bytes to %s, offset %d, area %d\n", + __func__, dwLen, Read ? "host" : "1401", dwOffs, wIdent); /* Amazingly, we can get an escape sequence back before the current staged Urb is done, so we */ /* have to check for this situation and, if so, wait until all is OK. */ if (pdx->bStagedUrbPending) { pdx->bXFerWaiting = true; /* Flag we are waiting */ dev_info(&pdx->interface->dev, - "%s xfer is waiting, as previous staged pending", + "%s: xfer is waiting, as previous staged pending\n", __func__); return U14ERR_NOERROR; } if (dwLen == 0) { /* allow 0-len read or write; just return success */ dev_dbg(&pdx->interface->dev, - "%s OK; zero-len read/write request", __func__); + "%s: OK; zero-len read/write request\n", __func__); return U14ERR_NOERROR; } @@ -795,7 +795,7 @@ int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent, bool bWait = false; /* Flag for transfer having to wait */ dev_dbg(&pdx->interface->dev, - "Circular buffers are %d at %d and %d at %d", + "Circular buffers are %d at %d and %d at %d\n", pArea->aBlocks[0].dwSize, pArea->aBlocks[0].dwOffset, pArea->aBlocks[1].dwSize, pArea->aBlocks[1].dwOffset); if (pArea->aBlocks[1].dwSize > 0) { /* Using the second block already? */ @@ -819,14 +819,14 @@ int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent, if (bWait) { /* This transfer will have to wait? */ pdx->bXFerWaiting = true; /* Flag we are waiting */ dev_dbg(&pdx->interface->dev, - "%s xfer waiting for circular buffer space", + "%s: xfer waiting for circular buffer space\n", __func__); return U14ERR_NOERROR; } dev_dbg(&pdx->interface->dev, - "%s circular xfer, %d bytes starting at %d", __func__, - dwLen, dwOffs); + "%s: circular xfer, %d bytes starting at %d\n", + __func__, dwLen, dwOffs); } /* Save the parameters for the read\write transfer */ pdx->StagedRead = Read; /* Save the parameters for this read */ @@ -948,7 +948,7 @@ static bool ReadDMAInfo(volatile DMADESC *pDmaDesc, DEVICE_EXTENSION *pdx, unsigned char ucData; unsigned int dDone = 0; /* We haven't parsed anything so far */ - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); if (ReadChar(&ucData, pBuf, &dDone, dwCount)) { unsigned char ucTransCode = (ucData & 0x0F); /* get code for transfer type */ @@ -960,8 +960,8 @@ static bool ReadDMAInfo(volatile DMADESC *pDmaDesc, DEVICE_EXTENSION *pdx, pDmaDesc->dwSize = 0; /* initialise other bits */ pDmaDesc->dwOffset = 0; - dev_dbg(&pdx->interface->dev, "%s type: %d ident: %d", __func__, - pDmaDesc->wTransType, pDmaDesc->wIdent); + dev_dbg(&pdx->interface->dev, "%s: type: %d ident: %d\n", + __func__, pDmaDesc->wTransType, pDmaDesc->wIdent); pDmaDesc->bOutWard = (ucTransCode != TM_EXTTOHOST); /* set transfer direction */ @@ -976,7 +976,7 @@ static bool ReadDMAInfo(volatile DMADESC *pDmaDesc, DEVICE_EXTENSION *pdx, &dDone, dwCount); if (bResult) { dev_dbg(&pdx->interface->dev, - "%s xfer offset & size %d %d", + "%s: xfer offset & size %d %d\n", __func__, pDmaDesc->dwOffset, pDmaDesc->dwSize); @@ -989,7 +989,7 @@ static bool ReadDMAInfo(volatile DMADESC *pDmaDesc, DEVICE_EXTENSION *pdx, dwLength))) { bResult = false; /* bad parameter(s) */ dev_dbg(&pdx->interface->dev, - "%s bad param - id %d, bUsed %d, offset %d, size %d, area length %d", + "%s: bad param - id %d, bUsed %d, offset %d, size %d, area length %d\n", __func__, wIdent, pdx->rTransDef[wIdent]. bUsed, @@ -1008,7 +1008,7 @@ static bool ReadDMAInfo(volatile DMADESC *pDmaDesc, DEVICE_EXTENSION *pdx, bResult = false; if (!bResult) /* now check parameters for validity */ - dev_err(&pdx->interface->dev, "%s error reading Esc sequence", + dev_err(&pdx->interface->dev, "%s: error reading Esc sequence\n", __func__); return bResult; @@ -1045,14 +1045,15 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh, unsigned short wTransType = pdx->rDMAInfo.wTransType; /* check transfer type */ dev_dbg(&pdx->interface->dev, - "%s xfer to %s, offset %d, length %d", __func__, + "%s: xfer to %s, offset %d, length %d\n", + __func__, pdx->rDMAInfo.bOutWard ? "1401" : "host", pdx->rDMAInfo.dwOffset, pdx->rDMAInfo.dwSize); if (pdx->bXFerWaiting) { /* Check here for badly out of kilter... */ /* This can never happen, really */ dev_err(&pdx->interface->dev, - "ERROR: DMA setup while transfer still waiting"); + "ERROR: DMA setup while transfer still waiting\n"); spin_unlock(&pdx->stagedLock); } else { if ((wTransType == TM_EXTTOHOST) @@ -1066,21 +1067,21 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh, pdx->rDMAInfo.dwSize); if (iReturn != U14ERR_NOERROR) dev_err(&pdx->interface->dev, - "%s ReadWriteMem() failed %d", + "%s: ReadWriteMem() failed %d\n", __func__, iReturn); } else /* This covers non-linear transfer setup */ dev_err(&pdx->interface->dev, - "%s Unknown block xfer type %d", + "%s: Unknown block xfer type %d\n", __func__, wTransType); } } else /* Failed to read parameters */ - dev_err(&pdx->interface->dev, "%s ReadDMAInfo() fail", + dev_err(&pdx->interface->dev, "%s: ReadDMAInfo() fail\n", __func__); spin_unlock(&pdx->stagedLock); /* OK here */ } - dev_dbg(&pdx->interface->dev, "%s returns %d", __func__, iReturn); + dev_dbg(&pdx->interface->dev, "%s: returns %d\n", __func__, iReturn); return iReturn; } @@ -1100,11 +1101,11 @@ static void ced_readchar_callback(struct urb *pUrb) (pUrb->status == -ENOENT || pUrb->status == -ECONNRESET || pUrb->status == -ESHUTDOWN)) { dev_err(&pdx->interface->dev, - "%s - nonzero write bulk status received: %d", + "%s: nonzero write bulk status received: %d\n", __func__, pUrb->status); } else dev_dbg(&pdx->interface->dev, - "%s - 0 chars pUrb->status=%d (shutdown?)", + "%s: 0 chars pUrb->status=%d (shutdown?)\n", __func__, pUrb->status); spin_lock(&pdx->err_lock); @@ -1125,7 +1126,7 @@ static void ced_readchar_callback(struct urb *pUrb) if (nGot < INBUF_SZ) { pdx->pCoherCharIn[nGot] = 0; /* tidy the string */ dev_dbg(&pdx->interface->dev, - "%s got %d chars >%s<", + "%s: got %d chars >%s<\n", __func__, nGot, pdx->pCoherCharIn); } @@ -1140,7 +1141,7 @@ static void ced_readchar_callback(struct urb *pUrb) if ((pdx->dwNumInput + nGot) <= INBUF_SZ) pdx->dwNumInput += nGot; /* Adjust the buffer count accordingly */ } else - dev_dbg(&pdx->interface->dev, "%s read ZLP", + dev_dbg(&pdx->interface->dev, "%s: read ZLP\n", __func__); } } @@ -1178,7 +1179,7 @@ int Allowi(DEVICE_EXTENSION *pdx) unsigned int nMax = INBUF_SZ - pdx->dwNumInput; /* max we could read */ int nPipe = pdx->nPipes == 4 ? 1 : 0; /* The pipe number to use */ - dev_dbg(&pdx->interface->dev, "%s %d chars in input buffer", + dev_dbg(&pdx->interface->dev, "%s: %d chars in input buffer\n", __func__, pdx->dwNumInput); usb_fill_int_urb(pdx->pUrbCharIn, pdx->udev, @@ -1192,7 +1193,8 @@ int Allowi(DEVICE_EXTENSION *pdx) usb_unanchor_urb(pdx->pUrbCharIn); /* remove from list of active Urbs */ pdx->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ dev_err(&pdx->interface->dev, - "%s submit urb failed: %d", __func__, iReturn); + "%s: submit urb failed: %d\n", + __func__, iReturn); } else pdx->bReadCharsPending = true; /* Flag that we are active here */ } @@ -1397,7 +1399,7 @@ static int ced_probe(struct usb_interface *interface, else if ((i >= 1) && (i <= 23)) pdx->s1401Type = i + 2; else { - dev_err(&interface->dev, "%s Unknown device. bcdDevice = %d", + dev_err(&interface->dev, "%s: Unknown device. bcdDevice = %d\n", __func__, bcdDevice); goto error; } @@ -1405,7 +1407,7 @@ static int ced_probe(struct usb_interface *interface, /* we know that we are dealing with a 1401 device. */ iface_desc = interface->cur_altsetting; pdx->nPipes = iface_desc->desc.bNumEndpoints; - dev_info(&interface->dev, "1401Type=%d with %d End Points", + dev_info(&interface->dev, "1401Type=%d with %d End Points\n", pdx->s1401Type, pdx->nPipes); if ((pdx->nPipes < 3) || (pdx->nPipes > 4)) goto error; @@ -1415,7 +1417,7 @@ static int ced_probe(struct usb_interface *interface, pdx->pUrbCharIn = usb_alloc_urb(0, GFP_KERNEL); /* character input URB */ pdx->pStagedUrb = usb_alloc_urb(0, GFP_KERNEL); /* block transfer URB */ if (!pdx->pUrbCharOut || !pdx->pUrbCharIn || !pdx->pStagedUrb) { - dev_err(&interface->dev, "%s URB alloc failed", __func__); + dev_err(&interface->dev, "%s: URB alloc failed\n", __func__); goto error; } @@ -1429,7 +1431,7 @@ static int ced_probe(struct usb_interface *interface, usb_alloc_coherent(pdx->udev, INBUF_SZ, GFP_KERNEL, &pdx->pUrbCharIn->transfer_dma); if (!pdx->pCoherCharOut || !pdx->pCoherCharIn || !pdx->pCoherStagedIO) { - dev_err(&interface->dev, "%s Coherent buffer alloc failed", + dev_err(&interface->dev, "%s: Coherent buffer alloc failed\n", __func__); goto error; } @@ -1437,19 +1439,19 @@ static int ced_probe(struct usb_interface *interface, for (i = 0; i < pdx->nPipes; ++i) { endpoint = &iface_desc->endpoint[i].desc; pdx->epAddr[i] = endpoint->bEndpointAddress; - dev_info(&interface->dev, "Pipe %d, ep address %02x", i, - pdx->epAddr[i]); + dev_info(&interface->dev, "Pipe %d, ep address %02x\n", + i, pdx->epAddr[i]); if (((pdx->nPipes == 3) && (i == 0)) || /* if char input end point */ ((pdx->nPipes == 4) && (i == 1))) { pdx->bInterval = endpoint->bInterval; /* save the endpoint interrupt interval */ - dev_info(&interface->dev, "Pipe %d, bInterval = %d", i, - pdx->bInterval); + dev_info(&interface->dev, "Pipe %d, bInterval = %d\n", + i, pdx->bInterval); } /* Detect USB2 by checking last ep size (64 if USB1) */ if (i == pdx->nPipes - 1) { /* if this is the last ep (bulk) */ pdx->bIsUSB2 = le16_to_cpu(endpoint->wMaxPacketSize) > 64; - dev_info(&pdx->interface->dev, "USB%d", + dev_info(&pdx->interface->dev, "USB%d\n", pdx->bIsUSB2 + 1); } } @@ -1462,14 +1464,14 @@ static int ced_probe(struct usb_interface *interface, if (retval) { /* something prevented us from registering this driver */ dev_err(&interface->dev, - "Not able to get a minor for this device.\n"); + "Not able to get a minor for this device\n"); usb_set_intfdata(interface, NULL); goto error; } /* let the user know what node this device is now attached to */ dev_info(&interface->dev, - "USB CEDUSB device now attached to cedusb #%d", + "USB CEDUSB device now attached to cedusb #%d\n", interface->minor); return 0; @@ -1493,7 +1495,7 @@ static void ced_disconnect(struct usb_interface *interface) for (i = 0; i < MAX_TRANSAREAS; ++i) { int iErr = ClearArea(pdx, i); /* ...release any used memory */ if (iErr == U14ERR_UNLOCKFAIL) - dev_err(&pdx->interface->dev, "%s Area %d was in used", + dev_err(&pdx->interface->dev, "%s: Area %d was in used\n", __func__, i); } pdx->interface = NULL; /* ...we kill off link to interface */ @@ -1503,7 +1505,7 @@ static void ced_disconnect(struct usb_interface *interface) kref_put(&pdx->kref, ced_delete); /* decrement our usage count */ - dev_info(&interface->dev, "USB cedusb #%d now disconnected", minor); + dev_info(&interface->dev, "USB cedusb #%d now disconnected\n", minor); } /* Wait for all the urbs we know of to be done with, then kill off any that */ @@ -1513,13 +1515,13 @@ static void ced_disconnect(struct usb_interface *interface) void ced_draw_down(DEVICE_EXTENSION *pdx) { int time; - dev_dbg(&pdx->interface->dev, "%s called", __func__); + dev_dbg(&pdx->interface->dev, "%s: called\n", __func__); pdx->bInDrawDown = true; time = usb_wait_anchor_empty_timeout(&pdx->submitted, 3000); if (!time) { /* if we timed out we kill the urbs */ usb_kill_anchored_urbs(&pdx->submitted); - dev_err(&pdx->interface->dev, "%s timed out", __func__); + dev_err(&pdx->interface->dev, "%s: timed out\n", __func__); } pdx->bInDrawDown = false; } @@ -1531,7 +1533,7 @@ static int ced_suspend(struct usb_interface *intf, pm_message_t message) return 0; ced_draw_down(pdx); - dev_dbg(&pdx->interface->dev, "%s called", __func__); + dev_dbg(&pdx->interface->dev, "%s: called\n", __func__); return 0; } @@ -1540,14 +1542,14 @@ static int ced_resume(struct usb_interface *intf) DEVICE_EXTENSION *pdx = usb_get_intfdata(intf); if (!pdx) return 0; - dev_dbg(&pdx->interface->dev, "%s called", __func__); + dev_dbg(&pdx->interface->dev, "%s: called\n", __func__); return 0; } static int ced_pre_reset(struct usb_interface *intf) { DEVICE_EXTENSION *pdx = usb_get_intfdata(intf); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); mutex_lock(&pdx->io_mutex); ced_draw_down(pdx); return 0; @@ -1556,7 +1558,7 @@ static int ced_pre_reset(struct usb_interface *intf) static int ced_post_reset(struct usb_interface *intf) { DEVICE_EXTENSION *pdx = usb_get_intfdata(intf); - dev_dbg(&pdx->interface->dev, "%s", __func__); + dev_dbg(&pdx->interface->dev, "%s\n", __func__); /* we are sure no URBs are active - no locking needed */ pdx->errors = -EPIPE; From 3a915dd250097ff3c6bb67a57f6b050f805ccdc2 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 14 Jan 2014 10:04:49 +0800 Subject: [PATCH 0040/1375] ion: Fix sparse non static symbol warnings Fixes the following sparse warnings: drivers/staging/android/ion/ion_dummy_driver.c:26:19: warning: symbol 'idev' was not declared. Should it be static? drivers/staging/android/ion/ion_dummy_driver.c:27:17: warning: symbol 'heaps' was not declared. Should it be static? drivers/staging/android/ion/ion_dummy_driver.c:29:6: warning: symbol 'carveout_ptr' was not declared. Should it be static? drivers/staging/android/ion/ion_dummy_driver.c:30:6: warning: symbol 'chunk_ptr' was not declared. Should it be static? drivers/staging/android/ion/ion_dummy_driver.c:32:26: warning: symbol 'dummy_heaps' was not declared. Should it be static? drivers/staging/android/ion/ion_dummy_driver.c:59:26: warning: symbol 'dummy_ion_pdata' was not declared. Should it be static? Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_dummy_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c index 55b2002753f2..b89004af05ff 100644 --- a/drivers/staging/android/ion/ion_dummy_driver.c +++ b/drivers/staging/android/ion/ion_dummy_driver.c @@ -23,13 +23,13 @@ #include "ion.h" #include "ion_priv.h" -struct ion_device *idev; -struct ion_heap **heaps; +static struct ion_device *idev; +static struct ion_heap **heaps; -void *carveout_ptr; -void *chunk_ptr; +static void *carveout_ptr; +static void *chunk_ptr; -struct ion_platform_heap dummy_heaps[] = { +static struct ion_platform_heap dummy_heaps[] = { { .id = ION_HEAP_TYPE_SYSTEM, .type = ION_HEAP_TYPE_SYSTEM, @@ -56,7 +56,7 @@ struct ion_platform_heap dummy_heaps[] = { }, }; -struct ion_platform_data dummy_ion_pdata = { +static struct ion_platform_data dummy_ion_pdata = { .nr = 4, .heaps = dummy_heaps, }; From 8aee843abb52c071f2da572723e1a7629f4b0df0 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Mon, 13 Jan 2014 21:13:16 -0600 Subject: [PATCH 0041/1375] Staging: comedi: remove unnecessary braces in pcl711.c This patch for pcl711.c removes braces causing a checkpatch.pl warning. It also removes an empty else arm of an if-else statement. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index f0fc123ef566..659578881a4e 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -336,11 +336,8 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); - if (cmd->stop_src == TRIG_NONE) { + if (cmd->stop_src == TRIG_NONE) err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); - } else { - /* ignore */ - } if (err) return 3; From 60738f605b9575714c8d959425b317692e72c6e3 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Thu, 16 Jan 2014 12:27:29 -0600 Subject: [PATCH 0042/1375] Staging: comedi: convert while loop to timeout in ni_mio_common.c This patch for ni_mio_common.c changes out a while loop for a timeout, which is preferred. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 457b88481db0..10c27cb278cb 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -687,12 +687,22 @@ static void ni_clear_ai_fifo(struct comedi_device *dev) { const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private; + static const int timeout = 10000; + int i; if (board->reg_type == ni_reg_6143) { /* Flush the 6143 data FIFO */ ni_writel(0x10, AIFIFO_Control_6143); /* Flush fifo */ ni_writel(0x00, AIFIFO_Control_6143); /* Flush fifo */ - while (ni_readl(AIFIFO_Status_6143) & 0x10) ; /* Wait for complete */ + /* Wait for complete */ + for (i = 0; i < timeout; i++) { + if (!(ni_readl(AIFIFO_Status_6143) & 0x10)) + break; + udelay(1); + } + if (i == timeout) { + comedi_error(dev, "FIFO flush timeout."); + } } else { devpriv->stc_writew(dev, 1, ADC_FIFO_Clear); if (board->reg_type == ni_reg_625x) { From de53d5266c9a1cf912741fb52791f27b2b1c7fd7 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:41 +0900 Subject: [PATCH 0043/1375] staging: dgap: Fix trailing whitespace in digi.h This patch fixed trailing whitespace error found by checkpatch.pl in dgap/digi.h Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/digi.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/dgap/digi.h b/drivers/staging/dgap/digi.h index bcea4f734a32..fe8790396713 100644 --- a/drivers/staging/dgap/digi.h +++ b/drivers/staging/dgap/digi.h @@ -43,7 +43,7 @@ #define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ #define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ -#ifndef TIOCM_LE +#ifndef TIOCM_LE #define TIOCM_LE 0x01 /* line enable */ #define TIOCM_DTR 0x02 /* data terminal ready */ #define TIOCM_RTS 0x04 /* request to send */ @@ -122,7 +122,7 @@ struct digiflow_t { #endif /************************************************************************ - * Values for digi_flags + * Values for digi_flags ************************************************************************/ #define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ #define DIGI_FAST 0x0002 /* Fast baud rates */ @@ -193,8 +193,8 @@ struct rw_t { #define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ /* Non-Zero Result codes. */ -#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ -#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ +#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ +#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ #define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ #define RESULT_TOOSML 4 /* Too small an area to shrink. */ #define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ @@ -205,7 +205,7 @@ struct shrink_buf_struct { unsigned long shrink_buf_bseg; /* Amount of board memory */ unsigned long shrink_buf_hseg; /* '186 Beginning of Dual-Port */ - unsigned long shrink_buf_lseg; /* '186 Beginning of freed memory */ + unsigned long shrink_buf_lseg; /* '186 Beginning of freed memory */ unsigned long shrink_buf_mseg; /* Linear address from start of dual-port were freed memory begins, host viewpoint. */ @@ -220,18 +220,18 @@ struct shrink_buf_struct { unsigned char shrink_buf_result; /* Reason for call failing Zero is Good return */ - unsigned char shrink_buf_init; /* Non-Zero if it caused an + unsigned char shrink_buf_init; /* Non-Zero if it caused an xxinit call. */ unsigned char shrink_buf_anports; /* Number of async ports */ unsigned char shrink_buf_snports; /* Number of sync ports */ unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, 2 = PC/Xm, - 3 = PC/Xe - 4 = MC/Xi + 3 = PC/Xe + 4 = MC/Xi 5 = COMX/i */ unsigned char shrink_buf_card; /* Card number */ - + }; /************************************************************************ @@ -244,7 +244,7 @@ struct digi_dinfo { }; #define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ - + /************************************************************************ * Structure used with ioctl commands for per-board information * @@ -264,7 +264,7 @@ struct digi_info { }; #define DIGI_GETBD ('d'<<8) | 249 /* get board info */ - + struct digi_stat { unsigned int info_chan; /* Channel number (0 based) */ unsigned int info_brd; /* Board number (0 based) */ @@ -299,7 +299,7 @@ struct digi_ch { }; /* -* This structure is used with the DIGI_FEPCMD ioctl to +* This structure is used with the DIGI_FEPCMD ioctl to * tell the driver which port to send the command for. */ struct digi_cmd { From 81db2e5c8669ea3db1551c3da843c037df1ce897 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:42 +0900 Subject: [PATCH 0044/1375] staging: dgap: Fix trailing whitespace in dgap_sysfs.c This patch fixed trailing whitespace found by checkpatch.pl in dgap/dgap_sysfs.c Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_sysfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c index 7f4ec9a18293..aa7e36f9d5d2 100644 --- a/drivers/staging/dgap/dgap_sysfs.c +++ b/drivers/staging/dgap/dgap_sysfs.c @@ -1,7 +1,7 @@ /* * Copyright 2004 Digi International (www.digi.com) * Scott H Kilau - * + * * 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) @@ -9,14 +9,14 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * + * * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! * * This is shared code between Digi's CVS archive and the @@ -28,8 +28,8 @@ * Thank you. * * - * - * $Id: dgap_sysfs.c,v 1.1 2009/10/23 14:01:57 markh Exp $ + * + * $Id: dgap_sysfs.c,v 1.1 2009/10/23 14:01:57 markh Exp $ */ @@ -41,7 +41,7 @@ #include #include #include - + #include "dgap_driver.h" #include "dgap_conf.h" #include "dgap_parse.h" @@ -130,7 +130,7 @@ void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) rc |= driver_create_file(driverfs, &driver_attr_boards); rc |= driver_create_file(driverfs, &driver_attr_maxboards); rc |= driver_create_file(driverfs, &driver_attr_debug); - rc |= driver_create_file(driverfs, &driver_attr_rawreadok); + rc |= driver_create_file(driverfs, &driver_attr_rawreadok); rc |= driver_create_file(driverfs, &driver_attr_pollrate); rc |= driver_create_file(driverfs, &driver_attr_pollcounter); rc |= driver_create_file(driverfs, &driver_attr_state); From 85025b64eacd4b72acb416aeda3ee7ae8734fa98 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:43 +0900 Subject: [PATCH 0045/1375] staging: dgap: Fix trailing whitespace in dgap_parse.c Thsi patch fixed trailing whitespace found by checkpatch.pl in dgap/dgap_parse.c Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_parse.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgap/dgap_parse.c b/drivers/staging/dgap/dgap_parse.c index 36fd93d3f5f6..7bc5bc326bf8 100644 --- a/drivers/staging/dgap/dgap_parse.c +++ b/drivers/staging/dgap/dgap_parse.c @@ -17,14 +17,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! * * This is shared code between Digi's CVS archive and the * Linux Kernel sources. * Changing the source just for reformatting needlessly breaks * our CVS diff history. * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * * @@ -340,7 +340,7 @@ int dgap_parsefile(char **in, int Remove) } p->u.board.v_pcislot = 1; - DPR_INIT(("Adding PCIINFO (%s %s) to config...\n", p->u.board.pcibusstr, + DPR_INIT(("Adding PCIINFO (%s %s) to config...\n", p->u.board.pcibusstr, p->u.board.pcislotstr)); break; @@ -914,7 +914,7 @@ static char *dgap_sindex (char *string, char *group) if (!string || !group) return (char *) NULL; - if (*group == '^') { + if (*group == '^') { group++; for (; *string; string++) { for (ptr = group; *ptr; ptr++) { @@ -924,7 +924,7 @@ static char *dgap_sindex (char *string, char *group) if (*ptr == '\0') return string; } - } + } else { for (; *string; string++) { for (ptr = group; *ptr; ptr++) { @@ -945,14 +945,14 @@ static int dgap_gettok(char **in, struct cnode *p) { char *w; struct toklist *t; - + if (strstr(dgap_cword, "boar")) { w = dgap_getword(in); snprintf(dgap_cword, MAXCWORD, "%s", w); for (t = dgap_tlist; t->token != 0; t++) { if ( !strcmp(w, t->string)) { return(t->token); - } + } } dgap_err("board !!type not specified"); return(1); @@ -1152,7 +1152,7 @@ uint dgap_config_get_altpin(struct board_t *bd) /* - * Given a specific type of board, if found, detached link and + * Given a specific type of board, if found, detached link and * returns the first occurrence in the list. */ struct cnode *dgap_find_config(int type, int bus, int slot) From 818cc6fe92076cb15312ba2c047988d4d9b1f6bb Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:44 +0900 Subject: [PATCH 0046/1375] staging: dgap: Fix trailing whitespace in dgap_driver.c This patch fixed trailing whitespace found by checkpatch.pl in staging/dgap/dgap_driver.c Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 089d017fc291..11dd6dd51ddb 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -6,12 +6,12 @@ * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -201,11 +201,11 @@ char *dgap_state_text[] = { "Need Device Creation", "Requested Device Creation", "Finished Device Creation", - "Need BIOS Load", - "Requested BIOS", + "Need BIOS Load", + "Requested BIOS", "Doing BIOS Load", "Finished BIOS Load", - "Need FEP Load", + "Need FEP Load", "Requested FEP", "Doing FEP Load", "Finished FEP Load", @@ -269,7 +269,7 @@ int dgap_init_module(void) else { dgap_create_driver_sysfiles(&dgap_driver); } - + DPR_INIT(("Finished init_module. Returning %d\n", rc)); return (rc); } @@ -326,7 +326,7 @@ static int dgap_start(void) if (rc < 0) { APR(("tty preinit - not enough memory (%d)\n", rc)); - return(rc); + return(rc); } /* Start the poller */ @@ -366,7 +366,7 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc < 0) { rc = -EIO; - } else { + } else { rc = dgap_probe1(pdev, ent->driver_data); if (rc == 0) { dgap_NumBoards++; @@ -374,15 +374,15 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) } } return rc; -} +} static int dgap_probe1(struct pci_dev *pdev, int card_type) { return dgap_found_board(pdev, card_type); } - - + + static void dgap_remove_one(struct pci_dev *dev) { /* Do Nothing */ @@ -599,7 +599,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id) pci_write_config_byte(pdev, 0x40, 0); pci_write_config_byte(pdev, 0x46, 0); - /* Limit burst length to 2 doubleword transactions */ + /* Limit burst length to 2 doubleword transactions */ pci_write_config_byte(pdev, 0x42, 1); /* @@ -718,23 +718,23 @@ static int dgap_do_remap(struct board_t *brd) /***************************************************************************** * * Function: -* +* * dgap_poll_handler * * Author: * * Scott H Kilau -* +* * Parameters: * -* dummy -- ignored +* dummy -- ignored * * Return Values: * * none * -* Description: -* +* Description: +* * As each timer expires, it determines (a) whether the "transmit" * waiter needs to be woken up, and (b) whether the poller needs to * be rescheduled. @@ -910,7 +910,7 @@ static void dgap_init_globals(void) dgap_Board[i] = NULL; } - init_timer( &dgap_poll_timer ); + init_timer( &dgap_poll_timer ); init_waitqueue_head(&dgap_dl_wait); dgap_dl_action = 0; From 5e5ccb48c1b63eef9bc7a85ae3184faa56f78e98 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:45 +0900 Subject: [PATCH 0047/1375] staging: dgap: Fix trailing whitespace in dgap_downld.h This patch fixed trailing whitespace found by checkpatch.pl in staging/dgap/dgap_downld.h Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_downld.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgap/dgap_downld.h b/drivers/staging/dgap/dgap_downld.h index 271ac19257f9..910a45d3f1f7 100644 --- a/drivers/staging/dgap/dgap_downld.h +++ b/drivers/staging/dgap/dgap_downld.h @@ -23,7 +23,7 @@ */ /* -** downld.h +** downld.h ** - describes the interface between the user level download process ** and the concentrator download driver. */ @@ -57,7 +57,7 @@ struct downldio { #define DIGI_NUKE_RESET_ALL (1 << 31) #define DIGI_NUKE_INHIBIT_POLLER (1 << 30) #define DIGI_NUKE_BRD_NUMB 0x0f - + #define DLREQ_BIOS 0 From a6224c369cdff4a856484898be5148dddcfc60c8 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:46 +0900 Subject: [PATCH 0048/1375] staging: dgap: Fix trailing whitespace in dgap_driver.h This patch fixed trailing whitespace found by checkpatch.pl in staging/dgap/dgap_driver.h Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 2f7a55a7e40d..48d2815520f5 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -58,7 +58,7 @@ #define PROCSTR "dgap" /* /proc entries */ #define DEVSTR "/dev/dg/dgap" /* /dev entries */ -#define DRVSTR "dgap" /* Driver name string +#define DRVSTR "dgap" /* Driver name string * displayed by APR */ #define APR(args) do { PRINTF_TO_KMEM(args); printk(DRVSTR": "); printk args; \ } while (0) @@ -112,7 +112,7 @@ #endif #if defined TRC_TO_KMEM -#define PRINTF_TO_KMEM(args) dgap_tracef args +#define PRINTF_TO_KMEM(args) dgap_tracef args #else //!defined TRC_TO_KMEM #define PRINTF_TO_KMEM(args) #endif @@ -192,7 +192,7 @@ * Our major for the mgmt devices. * * We can use 22, because Digi was allocated 22 and 23 for the epca driver. - * 22 has now become obsolete now that the "cu" devices have + * 22 has now become obsolete now that the "cu" devices have * been removed from 2.6. * Also, this *IS* the epca driver, just PCI only now. */ @@ -290,7 +290,7 @@ extern char *dgap_state_text[]; extern char *dgap_driver_state_text[]; -/* +/* * Modem line constants are defined as macros because DSR and * DCD are swapable using the ditty altpin option. */ @@ -322,7 +322,7 @@ struct macounter }; -/************************************************************************ +/************************************************************************ * Device flag definitions for bd_flags. ************************************************************************/ #define BD_FEP5PLUS 0x0001 /* Supports FEP5 Plus commands */ @@ -340,7 +340,7 @@ struct board_t int type; /* Type of board */ char *name; /* Product Name */ - struct pci_dev *pdev; /* Pointer to the pci_dev struct */ + struct pci_dev *pdev; /* Pointer to the pci_dev struct */ u16 vendor; /* PCI vendor ID */ u16 device; /* PCI device ID */ u16 subvendor; /* PCI subsystem vendor ID */ @@ -419,7 +419,7 @@ struct board_t -/************************************************************************ +/************************************************************************ * Unit flag definitions for un_flags. ************************************************************************/ #define UN_ISOPEN 0x0001 /* Device is open */ @@ -439,7 +439,7 @@ struct board_t struct device; /************************************************************************ - * Structure for terminal or printer unit. + * Structure for terminal or printer unit. ************************************************************************/ struct un_t { int magic; /* Unit Magic Number. */ @@ -457,7 +457,7 @@ struct un_t { }; -/************************************************************************ +/************************************************************************ * Device flag definitions for ch_flags. ************************************************************************/ #define CH_PRON 0x0001 /* Printer on string */ @@ -484,7 +484,7 @@ struct un_t { #define SNIFF_WAIT_SPACE 0x4 -/************************************************************************ +/************************************************************************ * Channel information structure. ************************************************************************/ struct channel_t { @@ -608,7 +608,7 @@ extern int dgap_registerttyswithsysfs; /* Should we register the */ * Global functions declared in dgap_fep5.c, but must be hidden from * user space programs. */ -extern void dgap_poll_tasklet(unsigned long data); +extern void dgap_poll_tasklet(unsigned long data); extern void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds); extern void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds); extern void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); From 0217ef98bcc521324c1f82803767cb3fd94ff6a6 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:47 +0900 Subject: [PATCH 0049/1375] staging: dgap: Fix trailing whitespace in dgap_sysfs.h This patch fixed trailing whitespace found by checkpatch.pl in staging/dgap/dgap_sysfs.h Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_sysfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_sysfs.h b/drivers/staging/dgap/dgap_sysfs.h index dde690eec5cf..151f1b32c76b 100644 --- a/drivers/staging/dgap/dgap_sysfs.h +++ b/drivers/staging/dgap/dgap_sysfs.h @@ -32,7 +32,7 @@ struct un_t; struct pci_driver; struct class_device; -extern void dgap_create_ports_sysfiles(struct board_t *bd); +extern void dgap_create_ports_sysfiles(struct board_t *bd); extern void dgap_remove_ports_sysfiles(struct board_t *bd); extern void dgap_create_driver_sysfiles(struct pci_driver *); From f513cb473f36a5988e58af01d2e4f86fcd31b4a0 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 15 Jan 2014 00:40:48 +0900 Subject: [PATCH 0050/1375] staging: dgap: Fix trailing whitespace in dgap_fep5.h This patch fixed trailing whitespace found by checkpatch.pl in staging/dgap/dgap_fep5.h Signed-off-by: Masanari Iida Acked-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_fep5.h | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/dgap/dgap_fep5.h b/drivers/staging/dgap/dgap_fep5.h index c9abc406a1e0..d0650ae2dd51 100644 --- a/drivers/staging/dgap/dgap_fep5.h +++ b/drivers/staging/dgap/dgap_fep5.h @@ -18,7 +18,7 @@ * * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! * - ************************************************************************ + ************************************************************************ *** FEP Version 5 dependent definitions ************************************************************************/ @@ -31,7 +31,7 @@ #define START 0x0004L /* Execution start address */ #define CMDBUF 0x0d10L /* Command (cm_t) structure offset */ -#define CMDSTART 0x0400L /* Start of command buffer */ +#define CMDSTART 0x0400L /* Start of command buffer */ #define CMDMAX 0x0800L /* End of command buffer */ #define EVBUF 0x0d18L /* Event (ev_t) structure */ @@ -51,7 +51,7 @@ #define FEPSTAT POSTAREA /* OS here when FEP comes up */ #define NCHAN 0x0C02L /* number of ports FEP sees */ #define PANIC 0x0C10L /* PANIC area for FEP */ -#define KMEMEM 0x0C30L /* Memory for KME use */ +#define KMEMEM 0x0C30L /* Memory for KME use */ #define CONFIG 0x0CD0L /* Concentrator configuration info */ #define CONFIGSIZE 0x0030 /* configuration info size */ #define DOWNREQ 0x0D00 /* Download request buffer pointer */ @@ -67,8 +67,8 @@ */ #define FEPCLR 0x00 -#define FEPMEM 0x02 -#define FEPRST 0x04 +#define FEPMEM 0x02 +#define FEPRST 0x04 #define FEPINT 0x08 #define FEPMASK 0x0e #define FEPWIN 0x80 @@ -79,13 +79,13 @@ #define FEPTIMEOUT 200000 #define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ -#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ +#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ #define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ -#define FEPPOLL 0x0c26 /* Fep event poll interval */ +#define FEPPOLL 0x0c26 /* Fep event poll interval */ #define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ -/************************************************************************ +/************************************************************************ * Command structure definition. ************************************************************************/ struct cm_t { @@ -119,13 +119,13 @@ struct downld_t { uchar dl_data[1024]; /* Download data */ }; -/************************************************************************ +/************************************************************************ * Per channel buffer structure ************************************************************************ - * Base Structure Entries Usage Meanings to Host * - * * - * W = read write R = read only * - * C = changed by commands only * + * Base Structure Entries Usage Meanings to Host * + * * + * W = read write R = read only * + * C = changed by commands only * * U = unknown (may be changed w/o notice) * ************************************************************************/ struct bs_t { @@ -138,7 +138,7 @@ struct bs_t { volatile unsigned short tx_head; /* W Tx buffer head offset */ volatile unsigned short tx_tail; /* R Tx buffer tail offset */ volatile unsigned short tx_max; /* W Tx buffer size - 1 */ - + volatile unsigned short rx_seg; /* W Rx segment */ volatile unsigned short rx_head; /* W Rx buffer head offset */ volatile unsigned short rx_tail; /* R Rx buffer tail offset */ @@ -179,7 +179,7 @@ struct bs_t { volatile unsigned char mtran; /* C Unreported modem trans */ volatile unsigned char orun; /* C Buffer overrun occurred */ - volatile unsigned char astartc; /* W Auxiliary Xon char */ + volatile unsigned char astartc; /* W Auxiliary Xon char */ volatile unsigned char astopc; /* W Auxiliary Xoff char */ volatile unsigned char startc; /* W Xon character */ volatile unsigned char stopc; /* W Xoff character */ @@ -190,13 +190,13 @@ struct bs_t { volatile unsigned char ochar; /* U Saved output character */ volatile unsigned char omask; /* U Output character mask */ - volatile unsigned char bfill[13]; /* U Reserved for expansion */ + volatile unsigned char bfill[13]; /* U Reserved for expansion */ volatile unsigned char scc[16]; /* U SCC registers */ }; -/************************************************************************ +/************************************************************************ * FEP supported functions ************************************************************************/ #define SRLOW 0xe0 /* Set receive low water */ @@ -207,12 +207,12 @@ struct bs_t { #define SMINT 0xe5 /* Set Modem Interrupt */ #define SAFLOWC 0xe6 /* Set Aux. flow control chars */ #define SBREAK 0xe8 /* Send break */ -#define SMODEM 0xe9 /* Set 8530 modem control lines */ +#define SMODEM 0xe9 /* Set 8530 modem control lines */ #define SIFLAG 0xea /* Set UNIX iflags */ #define SFLOWC 0xeb /* Set flow control characters */ #define STLOW 0xec /* Set transmit low water mark */ #define RPAUSE 0xee /* Pause receive */ -#define RRESUME 0xef /* Resume receive */ +#define RRESUME 0xef /* Resume receive */ #define CHRESET 0xf0 /* Reset Channel */ #define BUFSETALL 0xf2 /* Set Tx & Rx buffer size avail*/ #define SOFLAG 0xf3 /* Set UNIX oflags */ @@ -223,23 +223,23 @@ struct bs_t { #define SCOMMODE 0xfd /* Set RS232/422 mode */ -/************************************************************************ +/************************************************************************ * Modes for SCOMMODE ************************************************************************/ #define MODE_232 0x00 #define MODE_422 0x01 -/************************************************************************ +/************************************************************************ * Event flags. ************************************************************************/ -#define IFBREAK 0x01 /* Break received */ +#define IFBREAK 0x01 /* Break received */ #define IFTLW 0x02 /* Transmit low water */ #define IFTEM 0x04 /* Transmitter empty */ #define IFDATA 0x08 /* Receive data present */ #define IFMODEM 0x20 /* Modem status change */ -/************************************************************************ +/************************************************************************ * Modem flags ************************************************************************/ # define DM_RTS 0x02 /* Request to send */ From 60914a1ad338922e1038a51b613916a7cbc21cb1 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Fri, 17 Jan 2014 11:01:36 -0500 Subject: [PATCH 0051/1375] staging: dgap: removes KERNEL_VERSION conditionals This patch removes the KERNEL_VERSION conditionals. The driver is built for this kernel version, so the conditionals are not needed. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.h | 4 ---- drivers/staging/dgap/dgap_fep5.c | 36 +----------------------------- drivers/staging/dgap/dgap_tty.c | 25 +-------------------- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 48d2815520f5..f0f0430f9206 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -396,10 +396,6 @@ struct board_t u32 dgap_Serial_Major; u32 dgap_TransparentPrint_Major; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) - u32 TtyRefCnt; -#endif - struct bs_t *bd_bs; /* Base structure pointer */ char *flipbuf; /* Our flip buffer, alloced if board is found */ diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index f75831a422e8..0556f48c15de 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -30,10 +30,7 @@ #include #include /* For tty_schedule_flip */ #include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) #include -#endif #include "dgap_driver.h" #include "dgap_pci.h" @@ -1805,19 +1802,11 @@ static int dgap_event(struct board_t *bd) if (ch->ch_tun.un_flags & UN_ISOPEN) { if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) ch->ch_tun.un_tty->ldisc->ops->write_wakeup) -#else - ch->ch_tun.un_tty->ldisc.ops->write_wakeup) -#endif { DGAP_UNLOCK(ch->ch_lock, lock_flags2); DGAP_UNLOCK(bd->bd_lock, lock_flags); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); -#else - (ch->ch_tun.un_tty->ldisc.ops->write_wakeup)(ch->ch_tun.un_tty); -#endif DGAP_LOCK(bd->bd_lock, lock_flags); DGAP_LOCK(ch->ch_lock, lock_flags2); } @@ -1833,19 +1822,11 @@ static int dgap_event(struct board_t *bd) if (ch->ch_pun.un_flags & UN_ISOPEN) { if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) ch->ch_pun.un_tty->ldisc->ops->write_wakeup) -#else - ch->ch_pun.un_tty->ldisc.ops->write_wakeup) -#endif { DGAP_UNLOCK(ch->ch_lock, lock_flags2); DGAP_UNLOCK(bd->bd_lock, lock_flags); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); -#else - (ch->ch_pun.un_tty->ldisc.ops->write_wakeup)(ch->ch_pun.un_tty); -#endif DGAP_LOCK(bd->bd_lock, lock_flags); DGAP_LOCK(ch->ch_lock, lock_flags2); } @@ -1871,19 +1852,12 @@ static int dgap_event(struct board_t *bd) if (ch->ch_tun.un_flags & UN_ISOPEN) { if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) ch->ch_tun.un_tty->ldisc->ops->write_wakeup) -#else - ch->ch_tun.un_tty->ldisc.ops->write_wakeup) -#endif { DGAP_UNLOCK(ch->ch_lock, lock_flags2); DGAP_UNLOCK(bd->bd_lock, lock_flags); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); -#else - (ch->ch_tun.un_tty->ldisc.ops->write_wakeup)(ch->ch_tun.un_tty); -#endif DGAP_LOCK(bd->bd_lock, lock_flags); DGAP_LOCK(ch->ch_lock, lock_flags2); } @@ -1897,19 +1871,11 @@ static int dgap_event(struct board_t *bd) if (ch->ch_pun.un_flags & UN_ISOPEN) { if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) ch->ch_pun.un_tty->ldisc->ops->write_wakeup) -#else - ch->ch_pun.un_tty->ldisc.ops->write_wakeup) -#endif { DGAP_UNLOCK(ch->ch_lock, lock_flags2); DGAP_UNLOCK(bd->bd_lock, lock_flags); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); -#else - (ch->ch_pun.un_tty->ldisc.ops->write_wakeup)(ch->ch_pun.un_tty); -#endif DGAP_LOCK(bd->bd_lock, lock_flags); DGAP_LOCK(ch->ch_lock, lock_flags2); } diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 39fb4dfb8b7e..fdf8dc357ce0 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -61,11 +61,9 @@ #include "dgap_conf.h" #include "dgap_sysfs.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) #define init_MUTEX(sem) sema_init(sem, 1) #define DECLARE_MUTEX(name) \ struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) -#endif /* * internal variables @@ -131,13 +129,8 @@ static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, uns static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value); static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info); static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) static int dgap_tty_tiocmget(struct tty_struct *tty); static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); -#else -static int dgap_tty_tiocmget(struct tty_struct *tty, struct file *file); -static int dgap_tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -#endif static int dgap_tty_send_break(struct tty_struct *tty, int msec); static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout); static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); @@ -237,10 +230,6 @@ int dgap_tty_register(struct board_t *brd) if (!brd->SerialDriver->ttys) return(-ENOMEM); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) - brd->SerialDriver->refcount = brd->TtyRefCnt; -#endif - /* * Entry points for driver. Called by the kernel from * tty_io.c and n_tty.c. @@ -270,10 +259,6 @@ int dgap_tty_register(struct board_t *brd) if (!brd->PrintDriver->ttys) return(-ENOMEM); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) - brd->PrintDriver->refcount = brd->TtyRefCnt; -#endif - /* * Entry points for driver. Called by the kernel from * tty_io.c and n_tty.c. @@ -2109,11 +2094,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int /* * Return modem signals to ld. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) static int dgap_tty_tiocmget(struct tty_struct *tty) -#else -static int dgap_tty_tiocmget(struct tty_struct *tty, struct file *file) -#endif { struct channel_t *ch; struct un_t *un; @@ -2168,13 +2149,9 @@ static int dgap_tty_tiocmget(struct tty_struct *tty, struct file *file) * * Set modem signals, called by ld. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) -#else -static int dgap_tty_tiocmset(struct tty_struct *tty, struct file *file, - unsigned int set, unsigned int clear) -#endif { struct board_t *bd; struct channel_t *ch; From c34ca5a97bc3e90cab3af7e64c1c7c85302e6a09 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Fri, 17 Jan 2014 11:01:37 -0500 Subject: [PATCH 0052/1375] staging: dgap: removes version.h dependency This patch removes the version.h dependencies to the driver.h, fep5.c and tty.c files. This header was used to help the driver support different versions of the kernel. The support for different versions was removed in a previous patch. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.h | 1 - drivers/staging/dgap/dgap_fep5.c | 1 - drivers/staging/dgap/dgap_tty.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index f0f0430f9206..9296adcb06c9 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -27,7 +27,6 @@ #ifndef __DGAP_DRIVER_H #define __DGAP_DRIVER_H -#include /* To get the current Linux version */ #include /* To pick up the varions Linux types */ #include /* To pick up the various tty structs/defines */ #include /* For irqreturn_t type */ diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index 0556f48c15de..51cda71400f8 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -22,7 +22,6 @@ #include -#include #include #include #include /* For udelay */ diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index fdf8dc357ce0..565319f883cb 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -39,7 +39,6 @@ */ #include -#include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ #include From 6037b10655d7f0ffed42ada7364cf7508ff9a606 Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Sat, 18 Jan 2014 16:28:23 +0900 Subject: [PATCH 0053/1375] staging: crystalhd: enclose multi statements macro Enclose multiple statements macro with do - while block. Signed-off-by: SeongJae Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/crystalhd/crystalhd_hw.c b/drivers/staging/crystalhd/crystalhd_hw.c index 8d0680d93684..ccfa3b877a2e 100644 --- a/drivers/staging/crystalhd/crystalhd_hw.c +++ b/drivers/staging/crystalhd/crystalhd_hw.c @@ -433,10 +433,12 @@ static void crystalhd_rx_pkt_rel_call_back(void *context, void *data) } #define crystalhd_hw_delete_ioq(adp, q) \ +do { \ if (q) { \ crystalhd_delete_dioq(adp, q); \ q = NULL; \ - } + } \ +} while (0) static void crystalhd_hw_delete_ioqs(struct crystalhd_hw *hw) { From 6d213a450ec17089d0190ae35895b8ed375afc63 Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Sat, 18 Jan 2014 16:28:24 +0900 Subject: [PATCH 0054/1375] staging: crystalhd: remove unnecessary parenthesis Signed-off-by: SeongJae Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/crystalhd/crystalhd_hw.c b/drivers/staging/crystalhd/crystalhd_hw.c index ccfa3b877a2e..4765d528279b 100644 --- a/drivers/staging/crystalhd/crystalhd_hw.c +++ b/drivers/staging/crystalhd/crystalhd_hw.c @@ -1439,7 +1439,7 @@ static bool crystalhd_rx_list0_handler(struct crystalhd_hw *hw, crystalhd_reg_wr(hw->adp, MISC1_UV_RX_ERROR_STATUS, tmp); } - return (tmp_lsts != hw->rx_list_sts[0]); + return tmp_lsts != hw->rx_list_sts[0]; } static bool crystalhd_rx_list1_handler(struct crystalhd_hw *hw, @@ -1509,7 +1509,7 @@ static bool crystalhd_rx_list1_handler(struct crystalhd_hw *hw, crystalhd_reg_wr(hw->adp, MISC1_UV_RX_ERROR_STATUS, tmp); } - return (tmp_lsts != hw->rx_list_sts[1]); + return tmp_lsts != hw->rx_list_sts[1]; } From 86f78b8bf462555cbe0c3835b053c9739327287c Mon Sep 17 00:00:00 2001 From: Gary Rookard Date: Sat, 18 Jan 2014 17:05:09 -0500 Subject: [PATCH 0055/1375] Staging: bcm: DDRInit: fix up spacing issues. I fixed up some operator spacing issues. Signed-off-by: Gary Alan Rookard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/DDRInit.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index ed285b2d892d..b4d5e64cf47d 100644 --- a/drivers/staging/bcm/DDRInit.c +++ b/drivers/staging/bcm/DDRInit.c @@ -3,7 +3,7 @@ #define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00 -#define MIPS_CLOCK_REG 0x0f000820 +#define MIPS_CLOCK_REG 0x0f000820 /* DDR INIT-133Mhz */ #define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 /* index for 0x0F007000 */ @@ -818,13 +818,13 @@ int ddr_init(struct bcm_mini_adapter *Adapter) if ((Adapter->chip_id != BCS220_2) && (Adapter->chip_id != BCS220_2BC) && (Adapter->chip_id != BCS220_3)) { - retval = rdmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue |= 0x44; - retval = wrmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); + retval = wrmalt(Adapter, (UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -871,7 +871,7 @@ int ddr_init(struct bcm_mini_adapter *Adapter) case 0xbece0121: case 0xbece0130: case 0xbece0300: - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting); switch (Adapter->DDRSetting) { case DDR_80_MHZ: psDDRSetting = asT3_DDRSetting80MHz; @@ -933,7 +933,7 @@ int ddr_init(struct bcm_mini_adapter *Adapter) } value = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register Count is =%lu\n", RegCount); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register Count is =%lu\n", RegCount); while (RegCount && !retval) { if (uiClockSetting && psDDRSetting->ulRegAddress == MIPS_CLOCK_REG) value = uiClockSetting; @@ -990,12 +990,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) * we will change this when we will have internal PMU. */ if (Adapter->PmuMode == HYBRID_MODE_7C) { - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1006,12 +1006,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1024,12 +1024,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) } } else if (Adapter->PmuMode == HYBRID_MODE_6) { - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1040,12 +1040,12 @@ int ddr_init(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } - retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); + retval = rdmalt(Adapter, (UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if (retval < 0) { BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; @@ -1215,7 +1215,7 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) ul_ddr_setting_load_addr += sizeof(ULONG); if (!retval) { if (bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018)) { - value = (psDDRSetting->ulRegValue |(1<<8)); + value = (psDDRSetting->ulRegValue | (1<<8)); if (STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value))) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); From e7185c6958ee85b02629d95fe997977bb45e0393 Mon Sep 17 00:00:00 2001 From: Insop Song Date: Mon, 20 Jan 2014 23:47:06 -0800 Subject: [PATCH 0056/1375] staging: fpgaboot: Xilinx FPGA firmware download driver This driver downloads Xilinx FPGA firmware using gpio pins. It loads Xilinx FPGA bitstream format firmware image and program the Xilinx FPGA using SelectMAP (parallel) mode. Signed-off-by: Insop Song Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/gs_fpgaboot/Kconfig | 8 + drivers/staging/gs_fpgaboot/Makefile | 4 + drivers/staging/gs_fpgaboot/README | 71 ++++ drivers/staging/gs_fpgaboot/TODO | 7 + drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 425 ++++++++++++++++++++++ drivers/staging/gs_fpgaboot/gs_fpgaboot.h | 56 +++ drivers/staging/gs_fpgaboot/io.c | 294 +++++++++++++++ drivers/staging/gs_fpgaboot/io.h | 90 +++++ 10 files changed, 958 insertions(+) create mode 100644 drivers/staging/gs_fpgaboot/Kconfig create mode 100644 drivers/staging/gs_fpgaboot/Makefile create mode 100644 drivers/staging/gs_fpgaboot/README create mode 100644 drivers/staging/gs_fpgaboot/TODO create mode 100644 drivers/staging/gs_fpgaboot/gs_fpgaboot.c create mode 100644 drivers/staging/gs_fpgaboot/gs_fpgaboot.h create mode 100644 drivers/staging/gs_fpgaboot/io.c create mode 100644 drivers/staging/gs_fpgaboot/io.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 99375f0a9440..93a7ecf936ac 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -146,4 +146,6 @@ source "drivers/staging/dgnc/Kconfig" source "drivers/staging/dgap/Kconfig" +source "drivers/staging/gs_fpgaboot/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ddc3c4a5d39d..399f9fe07014 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -65,3 +65,4 @@ obj-$(CONFIG_XILLYBUS) += xillybus/ obj-$(CONFIG_DGNC) += dgnc/ obj-$(CONFIG_DGAP) += dgap/ obj-$(CONFIG_MTD_SPINAND_MT29F) += mt29f_spinand/ +obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ diff --git a/drivers/staging/gs_fpgaboot/Kconfig b/drivers/staging/gs_fpgaboot/Kconfig new file mode 100644 index 000000000000..550645291fab --- /dev/null +++ b/drivers/staging/gs_fpgaboot/Kconfig @@ -0,0 +1,8 @@ +# +# "xilinx FPGA firmware download, fpgaboot" +# +config GS_FPGABOOT + tristate "Xilinx FPGA firmware download module" + default n + help + Xilinx FPGA firmware download module diff --git a/drivers/staging/gs_fpgaboot/Makefile b/drivers/staging/gs_fpgaboot/Makefile new file mode 100644 index 000000000000..34cb606e0e3d --- /dev/null +++ b/drivers/staging/gs_fpgaboot/Makefile @@ -0,0 +1,4 @@ +gs_fpga-y += gs_fpgaboot.o io.o +obj-$(CONFIG_GS_FPGABOOT) += gs_fpga.o + +ccflags-$(CONFIG_GS_FPGA_DEBUG) := -DDEBUG diff --git a/drivers/staging/gs_fpgaboot/README b/drivers/staging/gs_fpgaboot/README new file mode 100644 index 000000000000..cfa8624304e5 --- /dev/null +++ b/drivers/staging/gs_fpgaboot/README @@ -0,0 +1,71 @@ +============================================================================== +Linux Driver Source for Xilinx FPGA firmware download +============================================================================== + + +TABLE OF CONTENTS. + +1. SUMMARY +2. BACKGROUND +3. DESIGN +4. HOW TO USE +5. REFERENCE + +1. SUMMARY + + - Download Xilinx FPGA firmware + - This module downloads Xilinx FPGA firmware using gpio pins. + +2. BACKGROUND + + An FPGA (Field Programmable Gate Array) is a programmable hardware that is + used in various applications. Hardware design needs to programmed through + a dedicated device or CPU assisted way (serial or parallel). + This driver provides a way to download FPGA firmware. + +3. DESIGN + + - load Xilinx FPGA bitstream format[1] firmware image file using + kernel firmware framework, request_firmware() + - program the Xilinx FPGA using SelectMAP (parallel) mode [2] + - FPGA prgram is done by gpio based bit-banging, as an example + - platform independent file: gs_fpgaboot.c + - platform dependent file: io.c + + +4. HOW TO USE + + $ insmod gs_fpga.ko file="xlinx_fpga_top_bitstream.bit" + $ rmmod gs_fpga + +5. USE CASE (from a mailing list discussion with Greg) + + a. As a FPGA development support tool, + During FPGA firmware development, you need to download a new FPGA + image frequently. + You would do that with a dedicated JTAG, which usually a limited + resource in the lab. + However, if you use my driver, you don't have to have a dedicated JTAG. + This is a real gain :) + + b. For the FPGA that runs without config after the download, which + doesn't talk to any of Linux interfaces (such as PCIE). + + We download FPGA firmware from user triggered or some other way, and that's it. + Since that FPGA runs on its own, it doesn't require a linux driver + after the download. + + c. For the FPGA that requires config after the download, which talk to + any of linux interfaces (such as PCIE) + + Then, this type of FPGA config can be put into device tree and have a + separate driver (pcie or others), then THAT driver calls my driver to + download FPGA firmware during the Linux boot, the take over the device + through the interface. + +6. REFERENCE + + 1. Xilinx APP NOTE XAPP583: + http://www.xilinx.com/support/documentation/application_notes/xapp583-fpga-configuration.pdf + 2. bitstream file info: + http://home.earthlink.net/~davesullins/software/bitinfo.html diff --git a/drivers/staging/gs_fpgaboot/TODO b/drivers/staging/gs_fpgaboot/TODO new file mode 100644 index 000000000000..2d9fb17d606d --- /dev/null +++ b/drivers/staging/gs_fpgaboot/TODO @@ -0,0 +1,7 @@ +TODO: + - get bus width input instead of hardcoded bus width + - get it reviewed + +Please send any patches for this driver to Insop Song +and Greg Kroah-Hartman . +And please CC to "Staging subsystem" mail list too. diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c new file mode 100644 index 000000000000..fee2f6140cae --- /dev/null +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -0,0 +1,425 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gs_fpgaboot.h" +#include "io.h" + +#define DEVICE_NAME "device" +#define CLASS_NAME "fpgaboot" + +static uint8_t bits_magic[] = { + 0x0, 0x9, 0xf, 0xf0, 0xf, 0xf0, + 0xf, 0xf0, 0xf, 0xf0, 0x0, 0x0, 0x1}; + +/* fake device for request_firmware */ +static struct platform_device *firmware_pdev; + +static char *file = "xlinx_fpga_firmware.bit"; +module_param(file, charp, S_IRUGO); +MODULE_PARM_DESC(file, "Xilinx FPGA firmware file."); + +#ifdef DEBUG_FPGA +static void datadump(char *msg, void *m, int n) +{ + int i; + unsigned char *c; + + pr_info("=== %s ===\n", msg); + + c = m; + + for (i = 0; i < n; i++) { + if ((i&0xf) == 0) + pr_info(KERN_INFO "\n 0x%4x: ", i); + + pr_info("%02X ", c[i]); + } + + pr_info("\n"); +} +#endif /* DEBUG_FPGA */ + +static void read_bitstream(char *bitdata, char *buf, int *offset, int rdsize) +{ + memcpy(buf, bitdata + *offset, rdsize); + *offset += rdsize; +} + +static void readinfo_bitstream(char *bitdata, char *buf, int *offset) +{ + char tbuf[64]; + int32_t len; + + /* read section char */ + read_bitstream(bitdata, tbuf, offset, 1); + + /* read length */ + read_bitstream(bitdata, tbuf, offset, 2); + + len = tbuf[0] << 8 | tbuf[1]; + + read_bitstream(bitdata, buf, offset, len); + buf[len] = '\0'; +} + +/* + * read bitdata length + */ +static int readlength_bitstream(char *bitdata, int *lendata, int *offset) +{ + char tbuf[64]; + + /* read section char */ + read_bitstream(bitdata, tbuf, offset, 1); + + /* make sure it is section 'e' */ + if (tbuf[0] != 'e') { + pr_err("error: length section is not 'e', but %c\n", tbuf[0]); + return -1; + } + + /* read 4bytes length */ + read_bitstream(bitdata, tbuf, offset, 4); + + *lendata = tbuf[0] << 24 | tbuf[1] << 16 | + tbuf[2] << 8 | tbuf[3]; + + return 0; +} + + +/* + * read first 13 bytes to check bitstream magic number + */ +static int readmagic_bitstream(char *bitdata, int *offset) +{ + char buf[13]; + int r; + + read_bitstream(bitdata, buf, offset, 13); + r = memcmp(buf, bits_magic, 13); + if (r) { + pr_err("error: corrupted header"); + return -1; + } + pr_info("bitstream file magic number Ok\n"); + + *offset = 13; /* magic length */ + + return 0; +} + +/* + * NOTE: supports only bitstream format + */ +static enum fmt_image get_imageformat(struct fpgaimage *fimage) +{ + return f_bit; +} + +static void gs_print_header(struct fpgaimage *fimage) +{ + pr_info("file: %s\n", fimage->filename); + pr_info("part: %s\n", fimage->part); + pr_info("date: %s\n", fimage->date); + pr_info("time: %s\n", fimage->time); + pr_info("lendata: %d\n", fimage->lendata); +} + +static void gs_read_bitstream(struct fpgaimage *fimage) +{ + char *bitdata; + int size; + int offset; + + offset = 0; + bitdata = (char *)fimage->fw_entry->data; + size = fimage->fw_entry->size; + + readmagic_bitstream(bitdata, &offset); + readinfo_bitstream(bitdata, fimage->filename, &offset); + readinfo_bitstream(bitdata, fimage->part, &offset); + readinfo_bitstream(bitdata, fimage->date, &offset); + readinfo_bitstream(bitdata, fimage->time, &offset); + readlength_bitstream(bitdata, &fimage->lendata, &offset); + + fimage->fpgadata = bitdata + offset; +} + +static int gs_read_image(struct fpgaimage *fimage) +{ + int img_fmt; + + img_fmt = get_imageformat(fimage); + + switch (img_fmt) { + case f_bit: + pr_info("image is bitstream format\n"); + gs_read_bitstream(fimage); + break; + default: + pr_err("unsupported fpga image format\n"); + return -1; + }; + + gs_print_header(fimage); + + return 0; +} + +static int gs_load_image(struct fpgaimage *fimage, char *file) +{ + int err; + + pr_info("load fpgaimage %s\n", file); + + err = request_firmware(&fimage->fw_entry, file, &firmware_pdev->dev); + if (err != 0) { + pr_err("firmware %s is missing, cannot continue.\n", file); + return err; + } + + return 0; +} + +static int gs_download_image(struct fpgaimage *fimage, enum wbus bus_bytes) +{ + char *bitdata; + int size, i, cnt; + cnt = 0; + + bitdata = (char *)fimage->fpgadata; + size = fimage->lendata; + +#ifdef DEBUG_FPGA + datadump("bitfile sample", bitdata, 0x100); +#endif /* DEBUG_FPGA */ + + if (!xl_supported_prog_bus_width(bus_bytes)) { + pr_err("unsupported program bus width %d\n", + bus_bytes); + return -1; + } + + /* Bring csi_b, rdwr_b Low and program_b High */ + xl_program_b(1); + xl_rdwr_b(0); + xl_csi_b(0); + + /* Configuration reset */ + xl_program_b(0); + msleep(20); + xl_program_b(1); + + /* Wait for Device Initialization */ + while (xl_get_init_b() == 0) + ; + + pr_info("device init done\n"); + + for (i = 0; i < size; i += bus_bytes) + xl_shift_bytes_out(bus_bytes, bitdata+i); + + pr_info("program done\n"); + + /* Check INIT_B */ + if (xl_get_init_b() == 0) { + pr_err("init_b 0\n"); + return -1; + } + + while (xl_get_done_b() == 0) { + if (cnt++ > MAX_WAIT_DONE) { + pr_err("init_B %d\n", xl_get_init_b()); + break; + } + } + + if (cnt > MAX_WAIT_DONE) { + pr_err("fpga download fail\n"); + return -1; + } + + pr_info("download fpgaimage\n"); + + /* Compensate for Special Startup Conditions */ + xl_shift_cclk(8); + + return 0; +} + +static int gs_release_image(struct fpgaimage *fimage) +{ + release_firmware(fimage->fw_entry); + pr_info("release fpgaimage\n"); + + return 0; +} + +/* + * NOTE: supports systemmap parallel programming + */ +static int gs_set_download_method(struct fpgaimage *fimage) +{ + pr_info("set program method\n"); + + fimage->dmethod = m_systemmap; + + pr_info("systemmap program method\n"); + + return 0; +} + +static int init_driver(void) +{ + firmware_pdev = platform_device_register_simple("fpgaboot", -1, + NULL, 0); + if (IS_ERR(firmware_pdev)) + return PTR_ERR(firmware_pdev); + + return 0; +} + +static void finish_driver(void) +{ + platform_device_unregister(firmware_pdev); +} + +static int gs_fpgaboot(void) +{ + int err; + struct fpgaimage *fimage; + + fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL); + if (fimage == NULL) { + pr_err("No memory is available\n"); + goto err_out; + } + + err = gs_load_image(fimage, file); + if (err) { + pr_err("gs_load_image error\n"); + goto err_out1; + } + + err = gs_read_image(fimage); + if (err) { + pr_err("gs_read_image error\n"); + goto err_out2; + } + + err = gs_set_download_method(fimage); + if (err) { + pr_err("gs_set_download_method error\n"); + goto err_out2; + } + + err = gs_download_image(fimage, bus_2byte); + if (err) { + pr_err("gs_download_image error\n"); + goto err_out2; + } + + err = gs_release_image(fimage); + if (err) { + pr_err("gs_release_image error\n"); + goto err_out1; + } + + kfree(fimage); + return 0; + +err_out2: + err = gs_release_image(fimage); + if (err) + pr_err("gs_release_image error\n"); +err_out1: + kfree(fimage); + +err_out: + return -1; + +} + +static int __init gs_fpgaboot_init(void) +{ + int err, r; + + r = -1; + + pr_info("FPGA DOWNLOAD --->\n"); + pr_info("built at %s UTC\n", __TIMESTAMP__); + + pr_info("FPGA image file name: %s\n", file); + + err = init_driver(); + if (err != 0) { + pr_err("FPGA DRIVER INIT FAIL!!\n"); + return r; + } + + err = xl_init_io(); + if (err) { + pr_err("GPIO INIT FAIL!!\n"); + r = -1; + goto errout; + } + + err = gs_fpgaboot(); + if (err) { + pr_err("FPGA DOWNLOAD FAIL!!\n"); + r = -1; + goto errout; + } + + pr_info("FPGA DOWNLOAD DONE <---\n"); + + r = 0; + return r; + +errout: + finish_driver(); + + return r; +} + +static void __exit gs_fpgaboot_exit(void) +{ + finish_driver(); + pr_info("FPGA image download module removed\n"); +} + +module_init(gs_fpgaboot_init); +module_exit(gs_fpgaboot_exit); + +MODULE_AUTHOR("Insop Song"); +MODULE_DESCRIPTION("Xlinix FPGA firmware download"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.h b/drivers/staging/gs_fpgaboot/gs_fpgaboot.h new file mode 100644 index 000000000000..f41f4cc798cc --- /dev/null +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.h @@ -0,0 +1,56 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +#define MAX_STR 256 + +enum fmt_image { + f_bit, /* only bitstream is supported */ + f_rbt, + f_bin, + f_mcs, + f_hex, +}; + +enum mdownload { + m_systemmap, /* only system map is supported */ + m_serial, + m_jtag, +}; + +/* + * xilinx fpgaimage information + * NOTE: use MAX_STR instead of dynamic alloc for simplicity + */ +struct fpgaimage { + enum fmt_image fmt_img; + enum mdownload dmethod; + + const struct firmware *fw_entry; + + /* + * the followings can be read from bitstream, + * but other image format should have as well + */ + char filename[MAX_STR]; + char part[MAX_STR]; + char date[MAX_STR]; + char time[MAX_STR]; + int32_t lendata; + char *fpgadata; +}; diff --git a/drivers/staging/gs_fpgaboot/io.c b/drivers/staging/gs_fpgaboot/io.c new file mode 100644 index 000000000000..61f976be5899 --- /dev/null +++ b/drivers/staging/gs_fpgaboot/io.c @@ -0,0 +1,294 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "io.h" + +#ifdef CONFIG_B4860G100 +static struct gpiobus gbus; +#endif /* CONFIG_B4860G100 */ + +static inline void byte0_out(unsigned char data); +static inline void byte1_out(unsigned char data); +static inline void xl_cclk_b(int32_t i); + + +/* Assert and Deassert CCLK */ +void xl_shift_cclk(int count) +{ + int i; + for (i = 0; i < count; i++) { + xl_cclk_b(1); + xl_cclk_b(0); + } +} + +int xl_supported_prog_bus_width(enum wbus bus_bytes) +{ + switch (bus_bytes) { + case bus_1byte: + break; + case bus_2byte: + break; + default: + pr_err("unsupported program bus width %d\n", + bus_bytes); + return 0; + } + + return 1; +} + +/* Serialize byte and clock each bit on target's DIN and CCLK pins */ +void xl_shift_bytes_out(enum wbus bus_byte, unsigned char *pdata) +{ + /* + * supports 1 and 2 bytes programming mode + */ + if (likely(bus_byte == bus_2byte)) + byte0_out(pdata[0]); + + byte1_out(pdata[1]); + xl_shift_cclk(1); +} + +/* + * generic bit swap for xilinx SYSTEMMAP FPGA programming + */ +static inline unsigned char bitswap(unsigned char s) +{ + unsigned char d; + d = (((s&0x80)>>7) | ((s&0x40)>>5) | ((s&0x20)>>3) | ((s&0x10)>>1) | + ((s&0x08)<<1) | ((s&0x04)<<3) | ((s&0x02)<<5) | ((s&0x01)<<7)); + return d; +} + +#ifdef CONFIG_B4860G100 +/* + * ====================================================================== + * board specific configuration + */ + +static inline void mpc85xx_gpio_set_dir( + int32_t port, + uint32_t mask, + uint32_t dir) +{ + dir |= (in_be32(gbus.r[port]+GPDIR) & ~mask); + out_be32(gbus.r[port]+GPDIR, dir); +} + +static inline void mpc85xx_gpio_set(int32_t port, uint32_t mask, uint32_t val) +{ + /* First mask off the unwanted parts of "dir" and "val" */ + val &= mask; + + /* Now read in the values we're supposed to preserve */ + val |= (in_be32(gbus.r[port]+GPDAT) & ~mask); + + out_be32(gbus.r[port]+GPDAT, val); +} + +static inline uint32_t mpc85xx_gpio_get(int32_t port, uint32_t mask) +{ + /* Read the requested values */ + return in_be32(gbus.r[port]+GPDAT) & mask; +} + +static inline void mpc85xx_gpio_set_low(int32_t port, uint32_t gpios) +{ + mpc85xx_gpio_set(port, gpios, 0x00000000); +} + +static inline void mpc85xx_gpio_set_high(int32_t port, uint32_t gpios) +{ + mpc85xx_gpio_set(port, gpios, 0xFFFFFFFF); +} + +static inline void gpio_set_value(int32_t port, uint32_t gpio, uint32_t value) +{ + int32_t g; + g = 31 - gpio; + if (value) + mpc85xx_gpio_set_high(port, 1U << g); + else + mpc85xx_gpio_set_low(port, 1U << g); +} + +static inline int gpio_get_value(int32_t port, uint32_t gpio) +{ + int32_t g; + g = 31 - gpio; + return !!mpc85xx_gpio_get(port, 1U << g); +} + +static inline void xl_cclk_b(int32_t i) +{ + gpio_set_value(XL_CCLK_PORT, XL_CCLK_PIN, i); +} + +void xl_program_b(int32_t i) +{ + gpio_set_value(XL_PROGN_PORT, XL_PROGN_PIN, i); +} + +void xl_rdwr_b(int32_t i) +{ + gpio_set_value(XL_RDWRN_PORT, XL_RDWRN_PIN, i); +} + +void xl_csi_b(int32_t i) +{ + gpio_set_value(XL_CSIN_PORT, XL_CSIN_PIN, i); +} + +int xl_get_init_b(void) +{ + return gpio_get_value(XL_INITN_PORT, XL_INITN_PIN); +} + +int xl_get_done_b(void) +{ + return gpio_get_value(XL_DONE_PORT, XL_DONE_PIN); +} + + +/* G100 specific bit swap and remmap (to gpio pins) for byte 0 */ +static inline uint32_t bit_remap_byte0(uint32_t s) +{ + uint32_t d; + d = (((s&0x80)>>7) | ((s&0x40)>>5) | ((s&0x20)>>3) | ((s&0x10)>>1) | + ((s&0x08)<<1) | ((s&0x04)<<3) | ((s&0x02)<<6) | ((s&0x01)<<9)); + return d; +} + +/* + * G100 specific MSB, in this order [byte0 | byte1], out + */ +static inline void byte0_out(unsigned char data) +{ + uint32_t swap32; + swap32 = bit_remap_byte0((uint32_t) data) << 8; + + mpc85xx_gpio_set(0, 0x0002BF00, (uint32_t) swap32); +} + +/* + * G100 specific LSB, in this order [byte0 | byte1], out + */ +static inline void byte1_out(unsigned char data) +{ + mpc85xx_gpio_set(0, 0x000000FF, (uint32_t) bitswap(data)); +} + +/* + * configurable per device type for different I/O config + */ +int xl_init_io() +{ + struct device_node *np; + const u32 *p_reg; + int reg, cnt; + + cnt = 0; + memset(&gbus, 0, sizeof(struct gpiobus)); + for_each_compatible_node(np, NULL, "fsl,qoriq-gpio") { + p_reg = of_get_property(np, "reg", NULL); + if (p_reg == NULL) + break; + reg = (int) *p_reg; + gbus.r[cnt] = of_iomap(np, 0); + + if (!gbus.r[cnt]) { + pr_err("not findding gpio cell-index %d\n", cnt); + return -ENODEV; + } + cnt++; + } + mpc85xx_gpio_set_dir(0, 0x0002BFFF, 0x0002BFFF); + mpc85xx_gpio_set_dir(1, 0x00240060, 0x00240060); + + gbus.ngpio = cnt; + + return 0; +} + + +#else /* placeholder for boards with different config */ + +void xl_program_b(int32_t i) +{ + return; +} + +void xl_rdwr_b(int32_t i) +{ + return; +} + +void xl_csi_b(int32_t i) +{ + return; +} + +int xl_get_init_b(void) +{ + return -1; +} + +int xl_get_done_b(void) +{ + return -1; +} + +static inline void byte0_out(unsigned char data) +{ + return; +} + +static inline void byte1_out(unsigned char data) +{ + return; +} + +static inline void xl_cclk_b(int32_t i) +{ + return; +} + +/* + * configurable per device type for different I/O config + */ +int xl_init_io() +{ + return -1; +} + +#endif /* CONFIG_B4860G100 */ diff --git a/drivers/staging/gs_fpgaboot/io.h b/drivers/staging/gs_fpgaboot/io.h new file mode 100644 index 000000000000..7b46ac24b74e --- /dev/null +++ b/drivers/staging/gs_fpgaboot/io.h @@ -0,0 +1,90 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define GPDIR 0 +#define GPCFG 4 /* open drain or not */ +#define GPDAT 8 + +/* + * gpio port and pin definitions + * NOTE: port number starts from 0 + */ +#define XL_INITN_PORT 1 +#define XL_INITN_PIN 14 +#define XL_RDWRN_PORT 1 +#define XL_RDWRN_PIN 13 +#define XL_CCLK_PORT 1 +#define XL_CCLK_PIN 10 +#define XL_PROGN_PORT 1 +#define XL_PROGN_PIN 25 +#define XL_CSIN_PORT 1 +#define XL_CSIN_PIN 26 +#define XL_DONE_PORT 1 +#define XL_DONE_PIN 27 + +/* + * gpio mapping + * + XL_config_D0 – gpio1_31 + Xl_config_d1 – gpio1_30 + Xl_config_d2 – gpio1_29 + Xl_config_d3 – gpio1_28 + Xl_config_d4 – gpio1_27 + Xl_config_d5 – gpio1_26 + Xl_config_d6 – gpio1_25 + Xl_config_d7 – gpio1_24 + Xl_config_d8 – gpio1_23 + Xl_config_d9 – gpio1_22 + Xl_config_d10 – gpio1_21 + Xl_config_d11 – gpio1_20 + Xl_config_d12 – gpio1_19 + Xl_config_d13 – gpio1_18 + Xl_config_d14 – gpio1_16 + Xl_config_d15 – gpio1_14 +* +*/ + +/* + * program bus width in bytes + */ +enum wbus { + bus_1byte = 1, + bus_2byte = 2, +}; + + +#define MAX_WAIT_DONE 10000 + + +struct gpiobus { + int ngpio; + void __iomem *r[4]; +}; + +int xl_supported_prog_bus_width(enum wbus bus_bytes); + +void xl_program_b(int32_t i); +void xl_rdwr_b(int32_t i); +void xl_csi_b(int32_t i); + +int xl_get_init_b(void); +int xl_get_done_b(void); + +void xl_shift_cclk(int count); +void xl_shift_bytes_out(enum wbus bus_byte, unsigned char *pdata); + +int xl_init_io(void); From be973fcd81c946e5e6ba2586718232e0fcf296e2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 7 Feb 2014 10:10:34 -0800 Subject: [PATCH 0057/1375] staging: vt6656: fix indentation in if statement Dave Jones pointed out that commit 302433daf47aeb7d21d66e55fb84d6a8fffd4aed (staging: vt6656: device.h Remove typedef enum __device_init_type.), improperly indented a line to make it look like it was under the if line above it, but it wasn't. So fix this up. Reported-by: Dave Jones Cc: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 58edcae74efc..6bd27cf43af7 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -409,7 +409,7 @@ static int device_init_registers(struct vnt_private *pDevice) if (pDevice->abyCCKPwrTbl[ii] == 0) pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr; - pDevice->abyOFDMPwrTbl[ii] = + pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL]; if (pDevice->abyOFDMPwrTbl[ii] == 0) pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG; From 91eef3e2fee581b00f027bbb0d144788a3c609a9 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Tue, 21 Jan 2014 21:56:27 +0100 Subject: [PATCH 0058/1375] staging/bluetooth: Add hci_h4p driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add hci_h4p bluetooth driver to staging tree. This device is used for example on Nokia N900 cell phone. Signed-off-by: Pali Rohár Signed-off-by: Pavel Machek Thanks-to: Sebastian Reichel Thanks-to: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nokia_h4p/Kconfig | 9 + drivers/staging/nokia_h4p/Makefile | 6 + drivers/staging/nokia_h4p/TODO | 140 +++ drivers/staging/nokia_h4p/hci_h4p.h | 228 ++++ drivers/staging/nokia_h4p/nokia_core.c | 1205 +++++++++++++++++++ drivers/staging/nokia_h4p/nokia_fw-bcm.c | 147 +++ drivers/staging/nokia_h4p/nokia_fw-csr.c | 150 +++ drivers/staging/nokia_h4p/nokia_fw-ti1273.c | 110 ++ drivers/staging/nokia_h4p/nokia_fw.c | 195 +++ drivers/staging/nokia_h4p/nokia_uart.c | 199 +++ include/linux/platform_data/bt-nokia-h4p.h | 38 + 13 files changed, 2430 insertions(+) create mode 100644 drivers/staging/nokia_h4p/Kconfig create mode 100644 drivers/staging/nokia_h4p/Makefile create mode 100644 drivers/staging/nokia_h4p/TODO create mode 100644 drivers/staging/nokia_h4p/hci_h4p.h create mode 100644 drivers/staging/nokia_h4p/nokia_core.c create mode 100644 drivers/staging/nokia_h4p/nokia_fw-bcm.c create mode 100644 drivers/staging/nokia_h4p/nokia_fw-csr.c create mode 100644 drivers/staging/nokia_h4p/nokia_fw-ti1273.c create mode 100644 drivers/staging/nokia_h4p/nokia_fw.c create mode 100644 drivers/staging/nokia_h4p/nokia_uart.c create mode 100644 include/linux/platform_data/bt-nokia-h4p.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 93a7ecf936ac..babb1cf67ce7 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -148,4 +148,6 @@ source "drivers/staging/dgap/Kconfig" source "drivers/staging/gs_fpgaboot/Kconfig" +source "drivers/staging/nokia_h4p/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 399f9fe07014..2c4949a9bd9b 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -66,3 +66,4 @@ obj-$(CONFIG_DGNC) += dgnc/ obj-$(CONFIG_DGAP) += dgap/ obj-$(CONFIG_MTD_SPINAND_MT29F) += mt29f_spinand/ obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ +obj-$(CONFIG_BT_NOKIA_H4P) += nokia_h4p/ diff --git a/drivers/staging/nokia_h4p/Kconfig b/drivers/staging/nokia_h4p/Kconfig new file mode 100644 index 000000000000..4336c0ad065b --- /dev/null +++ b/drivers/staging/nokia_h4p/Kconfig @@ -0,0 +1,9 @@ +config BT_NOKIA_H4P + tristate "HCI driver with H4 Nokia extensions" + depends on BT && ARCH_OMAP + help + Bluetooth HCI driver with H4 extensions. This driver provides + support for H4+ Bluetooth chip with vendor-specific H4 extensions. + + Say Y here to compile support for h4 extended devices into the kernel + or say M to compile it as module (btnokia_h4p). diff --git a/drivers/staging/nokia_h4p/Makefile b/drivers/staging/nokia_h4p/Makefile new file mode 100644 index 000000000000..9625db4a9af3 --- /dev/null +++ b/drivers/staging/nokia_h4p/Makefile @@ -0,0 +1,6 @@ + +obj-$(CONFIG_BT_NOKIA_H4P) += btnokia_h4p.o +btnokia_h4p-objs := nokia_core.o nokia_fw.o nokia_uart.o nokia_fw-csr.o \ + nokia_fw-bcm.o nokia_fw-ti1273.o + +ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/staging/nokia_h4p/TODO b/drivers/staging/nokia_h4p/TODO new file mode 100644 index 000000000000..d997afe14173 --- /dev/null +++ b/drivers/staging/nokia_h4p/TODO @@ -0,0 +1,140 @@ +Few attempts to submission have been made, last review comments were received in + +Date: Wed, 15 Jan 2014 19:01:51 -0800 +From: Marcel Holtmann +Subject: Re: [PATCH v6] Bluetooth: Add hci_h4p driver + +Some code refactoring is still needed. + +TODO: + +> +++ b/drivers/bluetooth/hci_h4p.h + +can we please get the naming straight. File names do not start with +hci_ anymore. We moved away from it since that term is too generic. + +> +#define FW_NAME_TI1271_LE "ti1273_le.bin" +> +#define FW_NAME_TI1271 "ti1273.bin" +> +#define FW_NAME_BCM2048 "bcmfw.bin" +> +#define FW_NAME_CSR "bc4fw.bin" + +We do these have to be global in a header file. This should be +confined to the specific firmware part. + +> +struct hci_h4p_info { + +Can we please get rid of the hci_ prefix for everything. Copying from +drivers that are over 10 years old is not a good idea. Please look at +recent ones. + +> + struct timer_list lazy_release; + +Timer? Not delayed work? + +> +void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val); +> +u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset); +> +void hci_h4p_set_rts(struct hci_h4p_info *info, int active); +> +int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, int timeout_ms); +> +void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); +> +void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); +> +void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed); +> +int hci_h4p_reset_uart(struct hci_h4p_info *info); +> +void hci_h4p_init_uart(struct hci_h4p_info *info); +> +void hci_h4p_enable_tx(struct hci_h4p_info *info); +> +void hci_h4p_store_regs(struct hci_h4p_info *info); +> +void hci_h4p_restore_regs(struct hci_h4p_info *info); +> +void hci_h4p_smart_idle(struct hci_h4p_info *info, bool enable); + +These are a lot of public functions. Are they all really needed or can +the code be done smart. + +> +static ssize_t hci_h4p_store_bdaddr(struct device *dev, +> + struct device_attribute *attr, +> + const char *buf, size_t count) +> +{ +> + struct hci_h4p_info *info = dev_get_drvdata(dev); + +Since none of these devices can function without having a valid +address, the way this should work is that we should not register the +HCI device when probing the platform device. + +The HCI device should be registered once a valid address has been +written into the sysfs file. I do not want to play the tricks with +bringing up the device without a valid address. + +> + hdev->close = hci_h4p_hci_close; +> + hdev->flush = hci_h4p_hci_flush; +> + hdev->send = hci_h4p_hci_send_frame; + +It needs to use hdev->setup to load the firmware. I assume the +firmware only needs to be loaded once. That is exactly what +hdev->setup does. It gets executed once. + +> + set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); + +Is this quirk really needed? Normally only Bluetooth 1.1 and early +devices qualify for it. + +> +static int hci_h4p_bcm_set_bdaddr(struct hci_h4p_info *info, struct sk_buff *skb) +> +{ +> + int i; +> + static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; +> + int not_valid; + +Has this actually been confirmed that we can just randomly set an +address out of the Nokia range. I do not think so. This is a pretty +bad idea. + +I have no interest in merging a driver with such a hack. + +> + not_valid = 1; +> + for (i = 0; i < 6; i++) { +> + if (info->bd_addr[i] != 0x00) { +> + not_valid = 0; +> + break; +> + } +> + } + +Anybody every heard of memcmp or bacmp and BDADDR_ANY? + +> + if (not_valid) { +> + dev_info(info->dev, "Valid bluetooth address not found," +> + " setting some random\n"); +> + /* When address is not valid, use some random */ +> + memcpy(info->bd_addr, nokia_oui, 3); +> + get_random_bytes(info->bd_addr + 3, 3); +> + } + + +And why does every single chip firmware does this differently. Seriously, this is a mess. + +> +void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) +> +{ +> + switch (info->man_id) { +> + case H4P_ID_CSR: +> + hci_h4p_bc4_parse_fw_event(info, skb); +> + break; +... +> +} + +We have proper HCI sync command handling in recent kernels. I really +do not know why this is hand coded these days. Check how the Intel +firmware loading inside btusb.c does it. + +> +inline u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset) +> +{ +> + return __raw_readb(info->uart_base + (offset << 2)); +> +} + +Inline in a *.c file for a non-static function. Makes no sense to me. + +> +/** +> + * struct hci_h4p_platform data - hci_h4p Platform data structure +> + */ +> +struct hci_h4p_platform_data { + +please have a proper name here. For example +btnokia_h4p_platform_data. + +Please send patches to Greg Kroah-Hartman and Cc: +Pavel Machek diff --git a/drivers/staging/nokia_h4p/hci_h4p.h b/drivers/staging/nokia_h4p/hci_h4p.h new file mode 100644 index 000000000000..fd7a6407f20c --- /dev/null +++ b/drivers/staging/nokia_h4p/hci_h4p.h @@ -0,0 +1,228 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2005-2008 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H +#define __DRIVERS_BLUETOOTH_HCI_H4P_H + +#include +#include +#include + +#define FW_NAME_TI1271_PRELE "ti1273_prele.bin" +#define FW_NAME_TI1271_LE "ti1273_le.bin" +#define FW_NAME_TI1271 "ti1273.bin" +#define FW_NAME_BCM2048 "bcmfw.bin" +#define FW_NAME_CSR "bc4fw.bin" + +#define UART_SYSC_OMAP_RESET 0x03 +#define UART_SYSS_RESETDONE 0x01 +#define UART_OMAP_SCR_EMPTY_THR 0x08 +#define UART_OMAP_SCR_WAKEUP 0x10 +#define UART_OMAP_SSR_WAKEUP 0x02 +#define UART_OMAP_SSR_TXFULL 0x01 + +#define UART_OMAP_SYSC_IDLEMODE 0x03 +#define UART_OMAP_SYSC_IDLEMASK (3 << UART_OMAP_SYSC_IDLEMODE) + +#define UART_OMAP_SYSC_FORCE_IDLE (0 << UART_OMAP_SYSC_IDLEMODE) +#define UART_OMAP_SYSC_NO_IDLE (1 << UART_OMAP_SYSC_IDLEMODE) +#define UART_OMAP_SYSC_SMART_IDLE (2 << UART_OMAP_SYSC_IDLEMODE) + +#define H4P_TRANSFER_MODE 1 +#define H4P_SCHED_TRANSFER_MODE 2 +#define H4P_ACTIVE_MODE 3 + +struct hci_h4p_info { + struct timer_list lazy_release; + struct hci_dev *hdev; + spinlock_t lock; + + void __iomem *uart_base; + unsigned long uart_phys_base; + int irq; + struct device *dev; + u8 chip_type; + u8 bt_wakeup_gpio; + u8 host_wakeup_gpio; + u8 reset_gpio; + u8 reset_gpio_shared; + u8 bt_sysclk; + u8 man_id; + u8 ver_id; + + struct sk_buff_head fw_queue; + struct sk_buff *alive_cmd_skb; + struct completion init_completion; + struct completion fw_completion; + struct completion test_completion; + int fw_error; + int init_error; + + struct sk_buff_head txq; + + struct sk_buff *rx_skb; + long rx_count; + unsigned long rx_state; + unsigned long garbage_bytes; + + u8 bd_addr[6]; + struct sk_buff_head *fw_q; + + int pm_enabled; + int tx_enabled; + int autorts; + int rx_enabled; + unsigned long pm_flags; + + int tx_clocks_en; + int rx_clocks_en; + spinlock_t clocks_lock; + struct clk *uart_iclk; + struct clk *uart_fclk; + atomic_t clk_users; + u16 dll; + u16 dlh; + u16 ier; + u16 mdr1; + u16 efr; +}; + +struct hci_h4p_radio_hdr { + __u8 evt; + __u8 dlen; +} __attribute__ ((packed)); + +struct hci_h4p_neg_hdr { + __u8 dlen; +} __attribute__ ((packed)); +#define H4P_NEG_HDR_SIZE 1 + +#define H4P_NEG_REQ 0x00 +#define H4P_NEG_ACK 0x20 +#define H4P_NEG_NAK 0x40 + +#define H4P_PROTO_PKT 0x44 +#define H4P_PROTO_BYTE 0x4c + +#define H4P_ID_CSR 0x02 +#define H4P_ID_BCM2048 0x04 +#define H4P_ID_TI1271 0x31 + +struct hci_h4p_neg_cmd { + __u8 ack; + __u16 baud; + __u16 unused1; + __u8 proto; + __u16 sys_clk; + __u16 unused2; +} __attribute__ ((packed)); + +struct hci_h4p_neg_evt { + __u8 ack; + __u16 baud; + __u16 unused1; + __u8 proto; + __u16 sys_clk; + __u16 unused2; + __u8 man_id; + __u8 ver_id; +} __attribute__ ((packed)); + +#define H4P_ALIVE_REQ 0x55 +#define H4P_ALIVE_RESP 0xcc + +struct hci_h4p_alive_hdr { + __u8 dlen; +} __attribute__ ((packed)); +#define H4P_ALIVE_HDR_SIZE 1 + +struct hci_h4p_alive_pkt { + __u8 mid; + __u8 unused; +} __attribute__ ((packed)); + +#define MAX_BAUD_RATE 921600 +#define BC4_MAX_BAUD_RATE 3692300 +#define UART_CLOCK 48000000 +#define BT_INIT_DIVIDER 320 +#define BT_BAUDRATE_DIVIDER 384000000 +#define BT_SYSCLK_DIV 1000 +#define INIT_SPEED 120000 + +#define H4_TYPE_SIZE 1 +#define H4_RADIO_HDR_SIZE 2 + +/* H4+ packet types */ +#define H4_CMD_PKT 0x01 +#define H4_ACL_PKT 0x02 +#define H4_SCO_PKT 0x03 +#define H4_EVT_PKT 0x04 +#define H4_NEG_PKT 0x06 +#define H4_ALIVE_PKT 0x07 +#define H4_RADIO_PKT 0x08 + +/* TX states */ +#define WAIT_FOR_PKT_TYPE 1 +#define WAIT_FOR_HEADER 2 +#define WAIT_FOR_DATA 3 + +struct hci_fw_event { + struct hci_event_hdr hev; + struct hci_ev_cmd_complete cmd; + u8 status; +} __attribute__ ((packed)); + +int hci_h4p_send_alive_packet(struct hci_h4p_info *info); + +void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, + struct sk_buff *skb); +int hci_h4p_bcm_send_fw(struct hci_h4p_info *info, + struct sk_buff_head *fw_queue); + +void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info *info, + struct sk_buff *skb); +int hci_h4p_bc4_send_fw(struct hci_h4p_info *info, + struct sk_buff_head *fw_queue); + +void hci_h4p_ti1273_parse_fw_event(struct hci_h4p_info *info, + struct sk_buff *skb); +int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info, + struct sk_buff_head *fw_queue); + +int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); +int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); +void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb); + +void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val); +u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset); +void hci_h4p_set_rts(struct hci_h4p_info *info, int active); +int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, int timeout_ms); +void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); +void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); +void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed); +int hci_h4p_reset_uart(struct hci_h4p_info *info); +void hci_h4p_init_uart(struct hci_h4p_info *info); +void hci_h4p_enable_tx(struct hci_h4p_info *info); +void hci_h4p_store_regs(struct hci_h4p_info *info); +void hci_h4p_restore_regs(struct hci_h4p_info *info); +void hci_h4p_smart_idle(struct hci_h4p_info *info, bool enable); + +#endif /* __DRIVERS_BLUETOOTH_HCI_H4P_H */ diff --git a/drivers/staging/nokia_h4p/nokia_core.c b/drivers/staging/nokia_h4p/nokia_core.c new file mode 100644 index 000000000000..5da84b06eff3 --- /dev/null +++ b/drivers/staging/nokia_h4p/nokia_core.c @@ -0,0 +1,1205 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2005-2008 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + * Thanks to all the Nokia people that helped with this driver, + * including Ville Tervo and Roger Quadros. + * + * Power saving functionality was removed from this driver to make + * merging easier. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "hci_h4p.h" + +/* This should be used in function that cannot release clocks */ +static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable) +{ + unsigned long flags; + + spin_lock_irqsave(&info->clocks_lock, flags); + if (enable && !*clock) { + BT_DBG("Enabling %p", clock); + clk_prepare_enable(info->uart_fclk); + clk_prepare_enable(info->uart_iclk); + if (atomic_read(&info->clk_users) == 0) + hci_h4p_restore_regs(info); + atomic_inc(&info->clk_users); + } + + if (!enable && *clock) { + BT_DBG("Disabling %p", clock); + if (atomic_dec_and_test(&info->clk_users)) + hci_h4p_store_regs(info); + clk_disable_unprepare(info->uart_fclk); + clk_disable_unprepare(info->uart_iclk); + } + + *clock = enable; + spin_unlock_irqrestore(&info->clocks_lock, flags); +} + +static void hci_h4p_lazy_clock_release(unsigned long data) +{ + struct hci_h4p_info *info = (struct hci_h4p_info *)data; + unsigned long flags; + + spin_lock_irqsave(&info->lock, flags); + if (!info->tx_enabled) + hci_h4p_set_clk(info, &info->tx_clocks_en, 0); + spin_unlock_irqrestore(&info->lock, flags); +} + +/* Power management functions */ +void hci_h4p_smart_idle(struct hci_h4p_info *info, bool enable) +{ + u8 v; + + v = hci_h4p_inb(info, UART_OMAP_SYSC); + v &= ~(UART_OMAP_SYSC_IDLEMASK); + + if (enable) + v |= UART_OMAP_SYSC_SMART_IDLE; + else + v |= UART_OMAP_SYSC_NO_IDLE; + + hci_h4p_outb(info, UART_OMAP_SYSC, v); +} + +static inline void h4p_schedule_pm(struct hci_h4p_info *info) +{ +} + +static void hci_h4p_disable_tx(struct hci_h4p_info *info) +{ + if (!info->pm_enabled) + return; + + /* Re-enable smart-idle */ + hci_h4p_smart_idle(info, 1); + + gpio_set_value(info->bt_wakeup_gpio, 0); + mod_timer(&info->lazy_release, jiffies + msecs_to_jiffies(100)); + info->tx_enabled = 0; +} + +void hci_h4p_enable_tx(struct hci_h4p_info *info) +{ + unsigned long flags; + + if (!info->pm_enabled) + return; + + h4p_schedule_pm(info); + + spin_lock_irqsave(&info->lock, flags); + del_timer(&info->lazy_release); + hci_h4p_set_clk(info, &info->tx_clocks_en, 1); + info->tx_enabled = 1; + gpio_set_value(info->bt_wakeup_gpio, 1); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + /* + * Disable smart-idle as UART TX interrupts + * are not wake-up capable + */ + hci_h4p_smart_idle(info, 0); + + spin_unlock_irqrestore(&info->lock, flags); +} + +static void hci_h4p_disable_rx(struct hci_h4p_info *info) +{ + if (!info->pm_enabled) + return; + + info->rx_enabled = 0; + + if (hci_h4p_inb(info, UART_LSR) & UART_LSR_DR) + return; + + if (!(hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT)) + return; + + __hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS); + info->autorts = 0; + hci_h4p_set_clk(info, &info->rx_clocks_en, 0); +} + +static void hci_h4p_enable_rx(struct hci_h4p_info *info) +{ + if (!info->pm_enabled) + return; + + h4p_schedule_pm(info); + + hci_h4p_set_clk(info, &info->rx_clocks_en, 1); + info->rx_enabled = 1; + + if (!(hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT)) + return; + + __hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_RTS); + info->autorts = 1; +} + +/* Negotiation functions */ +int hci_h4p_send_alive_packet(struct hci_h4p_info *info) +{ + struct hci_h4p_alive_hdr *hdr; + struct hci_h4p_alive_pkt *pkt; + struct sk_buff *skb; + unsigned long flags; + int len; + + BT_DBG("Sending alive packet"); + + len = H4_TYPE_SIZE + sizeof(*hdr) + sizeof(*pkt); + skb = bt_skb_alloc(len, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + memset(skb->data, 0x00, len); + *skb_put(skb, 1) = H4_ALIVE_PKT; + hdr = (struct hci_h4p_alive_hdr *)skb_put(skb, sizeof(*hdr)); + hdr->dlen = sizeof(*pkt); + pkt = (struct hci_h4p_alive_pkt *)skb_put(skb, sizeof(*pkt)); + pkt->mid = H4P_ALIVE_REQ; + + skb_queue_tail(&info->txq, skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); + + BT_DBG("Alive packet sent"); + + return 0; +} + +static void hci_h4p_alive_packet(struct hci_h4p_info *info, + struct sk_buff *skb) +{ + struct hci_h4p_alive_hdr *hdr; + struct hci_h4p_alive_pkt *pkt; + + BT_DBG("Received alive packet"); + hdr = (struct hci_h4p_alive_hdr *)skb->data; + if (hdr->dlen != sizeof(*pkt)) { + dev_err(info->dev, "Corrupted alive message\n"); + info->init_error = -EIO; + goto finish_alive; + } + + pkt = (struct hci_h4p_alive_pkt *)skb_pull(skb, sizeof(*hdr)); + if (pkt->mid != H4P_ALIVE_RESP) { + dev_err(info->dev, "Could not negotiate hci_h4p settings\n"); + info->init_error = -EINVAL; + } + +finish_alive: + complete(&info->init_completion); + kfree_skb(skb); +} + +static int hci_h4p_send_negotiation(struct hci_h4p_info *info) +{ + struct hci_h4p_neg_cmd *neg_cmd; + struct hci_h4p_neg_hdr *neg_hdr; + struct sk_buff *skb; + unsigned long flags; + int err, len; + u16 sysclk; + + BT_DBG("Sending negotiation.."); + + switch (info->bt_sysclk) { + case 1: + sysclk = 12000; + break; + case 2: + sysclk = 38400; + break; + default: + return -EINVAL; + } + + len = sizeof(*neg_cmd) + sizeof(*neg_hdr) + H4_TYPE_SIZE; + skb = bt_skb_alloc(len, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + memset(skb->data, 0x00, len); + *skb_put(skb, 1) = H4_NEG_PKT; + neg_hdr = (struct hci_h4p_neg_hdr *)skb_put(skb, sizeof(*neg_hdr)); + neg_cmd = (struct hci_h4p_neg_cmd *)skb_put(skb, sizeof(*neg_cmd)); + + neg_hdr->dlen = sizeof(*neg_cmd); + neg_cmd->ack = H4P_NEG_REQ; + neg_cmd->baud = cpu_to_le16(BT_BAUDRATE_DIVIDER/MAX_BAUD_RATE); + neg_cmd->proto = H4P_PROTO_BYTE; + neg_cmd->sys_clk = cpu_to_le16(sysclk); + + hci_h4p_change_speed(info, INIT_SPEED); + + hci_h4p_set_rts(info, 1); + info->init_error = 0; + init_completion(&info->init_completion); + skb_queue_tail(&info->txq, skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); + + if (!wait_for_completion_interruptible_timeout(&info->init_completion, + msecs_to_jiffies(1000))) + return -ETIMEDOUT; + + if (info->init_error < 0) + return info->init_error; + + /* Change to operational settings */ + hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS); + hci_h4p_set_rts(info, 0); + hci_h4p_change_speed(info, MAX_BAUD_RATE); + + err = hci_h4p_wait_for_cts(info, 1, 100); + if (err < 0) + return err; + + hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_RTS); + init_completion(&info->init_completion); + err = hci_h4p_send_alive_packet(info); + + if (err < 0) + return err; + + if (!wait_for_completion_interruptible_timeout(&info->init_completion, + msecs_to_jiffies(1000))) + return -ETIMEDOUT; + + if (info->init_error < 0) + return info->init_error; + + BT_DBG("Negotiation successful"); + return 0; +} + +static void hci_h4p_negotiation_packet(struct hci_h4p_info *info, + struct sk_buff *skb) +{ + struct hci_h4p_neg_hdr *hdr; + struct hci_h4p_neg_evt *evt; + + hdr = (struct hci_h4p_neg_hdr *)skb->data; + if (hdr->dlen != sizeof(*evt)) { + info->init_error = -EIO; + goto finish_neg; + } + + evt = (struct hci_h4p_neg_evt *)skb_pull(skb, sizeof(*hdr)); + + if (evt->ack != H4P_NEG_ACK) { + dev_err(info->dev, "Could not negotiate hci_h4p settings\n"); + info->init_error = -EINVAL; + } + + info->man_id = evt->man_id; + info->ver_id = evt->ver_id; + +finish_neg: + + complete(&info->init_completion); + kfree_skb(skb); +} + +/* H4 packet handling functions */ +static int hci_h4p_get_hdr_len(struct hci_h4p_info *info, u8 pkt_type) +{ + long retval; + + switch (pkt_type) { + case H4_EVT_PKT: + retval = HCI_EVENT_HDR_SIZE; + break; + case H4_ACL_PKT: + retval = HCI_ACL_HDR_SIZE; + break; + case H4_SCO_PKT: + retval = HCI_SCO_HDR_SIZE; + break; + case H4_NEG_PKT: + retval = H4P_NEG_HDR_SIZE; + break; + case H4_ALIVE_PKT: + retval = H4P_ALIVE_HDR_SIZE; + break; + case H4_RADIO_PKT: + retval = H4_RADIO_HDR_SIZE; + break; + default: + dev_err(info->dev, "Unknown H4 packet type 0x%.2x\n", pkt_type); + retval = -1; + break; + } + + return retval; +} + +static unsigned int hci_h4p_get_data_len(struct hci_h4p_info *info, + struct sk_buff *skb) +{ + long retval = -1; + struct hci_acl_hdr *acl_hdr; + struct hci_sco_hdr *sco_hdr; + struct hci_event_hdr *evt_hdr; + struct hci_h4p_neg_hdr *neg_hdr; + struct hci_h4p_alive_hdr *alive_hdr; + struct hci_h4p_radio_hdr *radio_hdr; + + switch (bt_cb(skb)->pkt_type) { + case H4_EVT_PKT: + evt_hdr = (struct hci_event_hdr *)skb->data; + retval = evt_hdr->plen; + break; + case H4_ACL_PKT: + acl_hdr = (struct hci_acl_hdr *)skb->data; + retval = le16_to_cpu(acl_hdr->dlen); + break; + case H4_SCO_PKT: + sco_hdr = (struct hci_sco_hdr *)skb->data; + retval = sco_hdr->dlen; + break; + case H4_RADIO_PKT: + radio_hdr = (struct hci_h4p_radio_hdr *)skb->data; + retval = radio_hdr->dlen; + break; + case H4_NEG_PKT: + neg_hdr = (struct hci_h4p_neg_hdr *)skb->data; + retval = neg_hdr->dlen; + break; + case H4_ALIVE_PKT: + alive_hdr = (struct hci_h4p_alive_hdr *)skb->data; + retval = alive_hdr->dlen; + break; + } + + return retval; +} + +static inline void hci_h4p_recv_frame(struct hci_h4p_info *info, + struct sk_buff *skb) +{ + if (unlikely(!test_bit(HCI_RUNNING, &info->hdev->flags))) { + switch (bt_cb(skb)->pkt_type) { + case H4_NEG_PKT: + hci_h4p_negotiation_packet(info, skb); + info->rx_state = WAIT_FOR_PKT_TYPE; + return; + case H4_ALIVE_PKT: + hci_h4p_alive_packet(info, skb); + info->rx_state = WAIT_FOR_PKT_TYPE; + return; + } + + if (!test_bit(HCI_UP, &info->hdev->flags)) { + BT_DBG("fw_event"); + hci_h4p_parse_fw_event(info, skb); + return; + } + } + + hci_recv_frame(info->hdev, skb); + BT_DBG("Frame sent to upper layer"); +} + +static inline void hci_h4p_handle_byte(struct hci_h4p_info *info, u8 byte) +{ + switch (info->rx_state) { + case WAIT_FOR_PKT_TYPE: + bt_cb(info->rx_skb)->pkt_type = byte; + info->rx_count = hci_h4p_get_hdr_len(info, byte); + if (info->rx_count < 0) { + info->hdev->stat.err_rx++; + kfree_skb(info->rx_skb); + info->rx_skb = NULL; + } else { + info->rx_state = WAIT_FOR_HEADER; + } + break; + case WAIT_FOR_HEADER: + info->rx_count--; + *skb_put(info->rx_skb, 1) = byte; + if (info->rx_count != 0) + break; + info->rx_count = hci_h4p_get_data_len(info, info->rx_skb); + if (info->rx_count > skb_tailroom(info->rx_skb)) { + dev_err(info->dev, "frame too long\n"); + info->garbage_bytes = info->rx_count + - skb_tailroom(info->rx_skb); + kfree_skb(info->rx_skb); + info->rx_skb = NULL; + break; + } + info->rx_state = WAIT_FOR_DATA; + break; + case WAIT_FOR_DATA: + info->rx_count--; + *skb_put(info->rx_skb, 1) = byte; + break; + default: + WARN_ON(1); + break; + } + + if (info->rx_count == 0) { + /* H4+ devices should always send word aligned packets */ + if (!(info->rx_skb->len % 2)) + info->garbage_bytes++; + hci_h4p_recv_frame(info, info->rx_skb); + info->rx_skb = NULL; + } +} + +static void hci_h4p_rx_tasklet(unsigned long data) +{ + u8 byte; + struct hci_h4p_info *info = (struct hci_h4p_info *)data; + + BT_DBG("tasklet woke up"); + BT_DBG("rx_tasklet woke up"); + + while (hci_h4p_inb(info, UART_LSR) & UART_LSR_DR) { + byte = hci_h4p_inb(info, UART_RX); + if (info->garbage_bytes) { + info->garbage_bytes--; + continue; + } + if (info->rx_skb == NULL) { + info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, + GFP_ATOMIC | GFP_DMA); + if (!info->rx_skb) { + dev_err(info->dev, + "No memory for new packet\n"); + goto finish_rx; + } + info->rx_state = WAIT_FOR_PKT_TYPE; + info->rx_skb->dev = (void *)info->hdev; + } + info->hdev->stat.byte_rx++; + hci_h4p_handle_byte(info, byte); + } + + if (!info->rx_enabled) { + if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT && + info->autorts) { + __hci_h4p_set_auto_ctsrts(info, 0 , UART_EFR_RTS); + info->autorts = 0; + } + /* Flush posted write to avoid spurious interrupts */ + hci_h4p_inb(info, UART_OMAP_SCR); + hci_h4p_set_clk(info, &info->rx_clocks_en, 0); + } + +finish_rx: + BT_DBG("rx_ended"); +} + +static void hci_h4p_tx_tasklet(unsigned long data) +{ + unsigned int sent = 0; + struct sk_buff *skb; + struct hci_h4p_info *info = (struct hci_h4p_info *)data; + + BT_DBG("tasklet woke up"); + BT_DBG("tx_tasklet woke up"); + + if (info->autorts != info->rx_enabled) { + if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) { + if (info->autorts && !info->rx_enabled) { + __hci_h4p_set_auto_ctsrts(info, 0, + UART_EFR_RTS); + info->autorts = 0; + } + if (!info->autorts && info->rx_enabled) { + __hci_h4p_set_auto_ctsrts(info, 1, + UART_EFR_RTS); + info->autorts = 1; + } + } else { + hci_h4p_outb(info, UART_OMAP_SCR, + hci_h4p_inb(info, UART_OMAP_SCR) | + UART_OMAP_SCR_EMPTY_THR); + goto finish_tx; + } + } + + skb = skb_dequeue(&info->txq); + if (!skb) { + /* No data in buffer */ + BT_DBG("skb ready"); + if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) { + hci_h4p_outb(info, UART_IER, + hci_h4p_inb(info, UART_IER) & + ~UART_IER_THRI); + hci_h4p_inb(info, UART_OMAP_SCR); + hci_h4p_disable_tx(info); + return; + } + hci_h4p_outb(info, UART_OMAP_SCR, + hci_h4p_inb(info, UART_OMAP_SCR) | + UART_OMAP_SCR_EMPTY_THR); + goto finish_tx; + } + + /* Copy data to tx fifo */ + while (!(hci_h4p_inb(info, UART_OMAP_SSR) & UART_OMAP_SSR_TXFULL) && + (sent < skb->len)) { + hci_h4p_outb(info, UART_TX, skb->data[sent]); + sent++; + } + + info->hdev->stat.byte_tx += sent; + if (skb->len == sent) { + kfree_skb(skb); + } else { + skb_pull(skb, sent); + skb_queue_head(&info->txq, skb); + } + + hci_h4p_outb(info, UART_OMAP_SCR, hci_h4p_inb(info, UART_OMAP_SCR) & + ~UART_OMAP_SCR_EMPTY_THR); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + +finish_tx: + /* Flush posted write to avoid spurious interrupts */ + hci_h4p_inb(info, UART_OMAP_SCR); + +} + +static irqreturn_t hci_h4p_interrupt(int irq, void *data) +{ + struct hci_h4p_info *info = (struct hci_h4p_info *)data; + u8 iir, msr; + int ret; + + ret = IRQ_NONE; + + iir = hci_h4p_inb(info, UART_IIR); + if (iir & UART_IIR_NO_INT) + return IRQ_HANDLED; + + BT_DBG("In interrupt handler iir 0x%.2x", iir); + + iir &= UART_IIR_ID; + + if (iir == UART_IIR_MSI) { + msr = hci_h4p_inb(info, UART_MSR); + ret = IRQ_HANDLED; + } + if (iir == UART_IIR_RLSI) { + hci_h4p_inb(info, UART_RX); + hci_h4p_inb(info, UART_LSR); + ret = IRQ_HANDLED; + } + + if (iir == UART_IIR_RDI) { + hci_h4p_rx_tasklet((unsigned long)data); + ret = IRQ_HANDLED; + } + + if (iir == UART_IIR_THRI) { + hci_h4p_tx_tasklet((unsigned long)data); + ret = IRQ_HANDLED; + } + + return ret; +} + +static irqreturn_t hci_h4p_wakeup_interrupt(int irq, void *dev_inst) +{ + struct hci_h4p_info *info = dev_inst; + int should_wakeup; + struct hci_dev *hdev; + + if (!info->hdev) + return IRQ_HANDLED; + + should_wakeup = gpio_get_value(info->host_wakeup_gpio); + hdev = info->hdev; + + if (!test_bit(HCI_RUNNING, &hdev->flags)) { + if (should_wakeup == 1) + complete_all(&info->test_completion); + + return IRQ_HANDLED; + } + + BT_DBG("gpio interrupt %d", should_wakeup); + + /* Check if wee have missed some interrupts */ + if (info->rx_enabled == should_wakeup) + return IRQ_HANDLED; + + if (should_wakeup) + hci_h4p_enable_rx(info); + else + hci_h4p_disable_rx(info); + + return IRQ_HANDLED; +} + +static inline void hci_h4p_set_pm_limits(struct hci_h4p_info *info, bool set) +{ + struct hci_h4p_platform_data *bt_plat_data = info->dev->platform_data; + const char *sset = set ? "set" : "clear"; + + if (unlikely(!bt_plat_data || !bt_plat_data->set_pm_limits)) + return; + + if (set != !!test_bit(H4P_ACTIVE_MODE, &info->pm_flags)) { + bt_plat_data->set_pm_limits(info->dev, set); + if (set) + set_bit(H4P_ACTIVE_MODE, &info->pm_flags); + else + clear_bit(H4P_ACTIVE_MODE, &info->pm_flags); + BT_DBG("Change pm constraints to: %s", sset); + return; + } + + BT_DBG("pm constraints remains: %s", sset); +} + +static int hci_h4p_reset(struct hci_h4p_info *info) +{ + int err; + + err = hci_h4p_reset_uart(info); + if (err < 0) { + dev_err(info->dev, "Uart reset failed\n"); + return err; + } + hci_h4p_init_uart(info); + hci_h4p_set_rts(info, 0); + + gpio_set_value(info->reset_gpio, 0); + gpio_set_value(info->bt_wakeup_gpio, 1); + msleep(10); + + if (gpio_get_value(info->host_wakeup_gpio) == 1) { + dev_err(info->dev, "host_wakeup_gpio not low\n"); + return -EPROTO; + } + + init_completion(&info->test_completion); + gpio_set_value(info->reset_gpio, 1); + + if (!wait_for_completion_interruptible_timeout(&info->test_completion, + msecs_to_jiffies(100))) { + dev_err(info->dev, "wakeup test timed out\n"); + complete_all(&info->test_completion); + return -EPROTO; + } + + err = hci_h4p_wait_for_cts(info, 1, 100); + if (err < 0) { + dev_err(info->dev, "No cts from bt chip\n"); + return err; + } + + hci_h4p_set_rts(info, 1); + + return 0; +} + +/* hci callback functions */ +static int hci_h4p_hci_flush(struct hci_dev *hdev) +{ + struct hci_h4p_info *info = hci_get_drvdata(hdev); + skb_queue_purge(&info->txq); + + return 0; +} + +static int hci_h4p_bt_wakeup_test(struct hci_h4p_info *info) +{ + /* + * Test Sequence: + * Host de-asserts the BT_WAKE_UP line. + * Host polls the UART_CTS line, waiting for it to be de-asserted. + * Host asserts the BT_WAKE_UP line. + * Host polls the UART_CTS line, waiting for it to be asserted. + * Host de-asserts the BT_WAKE_UP line (allow the Bluetooth device to + * sleep). + * Host polls the UART_CTS line, waiting for it to be de-asserted. + */ + int err; + int ret = -ECOMM; + + if (!info) + return -EINVAL; + + /* Disable wakeup interrupts */ + disable_irq(gpio_to_irq(info->host_wakeup_gpio)); + + gpio_set_value(info->bt_wakeup_gpio, 0); + err = hci_h4p_wait_for_cts(info, 0, 100); + if (err) { + dev_warn(info->dev, "bt_wakeup_test: fail: " + "CTS low timed out: %d\n", err); + goto out; + } + + gpio_set_value(info->bt_wakeup_gpio, 1); + err = hci_h4p_wait_for_cts(info, 1, 100); + if (err) { + dev_warn(info->dev, "bt_wakeup_test: fail: " + "CTS high timed out: %d\n", err); + goto out; + } + + gpio_set_value(info->bt_wakeup_gpio, 0); + err = hci_h4p_wait_for_cts(info, 0, 100); + if (err) { + dev_warn(info->dev, "bt_wakeup_test: fail: " + "CTS re-low timed out: %d\n", err); + goto out; + } + + ret = 0; + +out: + + /* Re-enable wakeup interrupts */ + enable_irq(gpio_to_irq(info->host_wakeup_gpio)); + + return ret; +} + +static int hci_h4p_hci_open(struct hci_dev *hdev) +{ + struct hci_h4p_info *info; + int err, retries = 0; + struct sk_buff_head fw_queue; + unsigned long flags; + + info = hci_get_drvdata(hdev); + + if (test_bit(HCI_RUNNING, &hdev->flags)) + return 0; + + /* TI1271 has HW bug and boot up might fail. Retry up to three times */ +again: + + info->rx_enabled = 1; + info->rx_state = WAIT_FOR_PKT_TYPE; + info->rx_count = 0; + info->garbage_bytes = 0; + info->rx_skb = NULL; + info->pm_enabled = 0; + init_completion(&info->fw_completion); + hci_h4p_set_clk(info, &info->tx_clocks_en, 1); + hci_h4p_set_clk(info, &info->rx_clocks_en, 1); + skb_queue_head_init(&fw_queue); + + err = hci_h4p_reset(info); + if (err < 0) + goto err_clean; + + hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_CTS | UART_EFR_RTS); + info->autorts = 1; + + err = hci_h4p_send_negotiation(info); + + err = hci_h4p_read_fw(info, &fw_queue); + if (err < 0) { + dev_err(info->dev, "Cannot read firmware\n"); + goto err_clean; + } + + err = hci_h4p_send_fw(info, &fw_queue); + if (err < 0) { + dev_err(info->dev, "Sending firmware failed.\n"); + goto err_clean; + } + + info->pm_enabled = 1; + + err = hci_h4p_bt_wakeup_test(info); + if (err < 0) { + dev_err(info->dev, "BT wakeup test failed.\n"); + goto err_clean; + } + + spin_lock_irqsave(&info->lock, flags); + info->rx_enabled = gpio_get_value(info->host_wakeup_gpio); + hci_h4p_set_clk(info, &info->rx_clocks_en, info->rx_enabled); + spin_unlock_irqrestore(&info->lock, flags); + + hci_h4p_set_clk(info, &info->tx_clocks_en, 0); + + kfree_skb(info->alive_cmd_skb); + info->alive_cmd_skb = NULL; + set_bit(HCI_RUNNING, &hdev->flags); + + BT_DBG("hci up and running"); + return 0; + +err_clean: + hci_h4p_hci_flush(hdev); + hci_h4p_reset_uart(info); + del_timer_sync(&info->lazy_release); + hci_h4p_set_clk(info, &info->tx_clocks_en, 0); + hci_h4p_set_clk(info, &info->rx_clocks_en, 0); + gpio_set_value(info->reset_gpio, 0); + gpio_set_value(info->bt_wakeup_gpio, 0); + skb_queue_purge(&fw_queue); + kfree_skb(info->alive_cmd_skb); + info->alive_cmd_skb = NULL; + kfree_skb(info->rx_skb); + info->rx_skb = NULL; + + if (retries++ < 3) { + dev_err(info->dev, "FW loading try %d fail. Retry.\n", retries); + goto again; + } + + return err; +} + +static int hci_h4p_hci_close(struct hci_dev *hdev) +{ + struct hci_h4p_info *info = hci_get_drvdata(hdev); + + if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) + return 0; + + hci_h4p_hci_flush(hdev); + hci_h4p_set_clk(info, &info->tx_clocks_en, 1); + hci_h4p_set_clk(info, &info->rx_clocks_en, 1); + hci_h4p_reset_uart(info); + del_timer_sync(&info->lazy_release); + hci_h4p_set_clk(info, &info->tx_clocks_en, 0); + hci_h4p_set_clk(info, &info->rx_clocks_en, 0); + gpio_set_value(info->reset_gpio, 0); + gpio_set_value(info->bt_wakeup_gpio, 0); + kfree_skb(info->rx_skb); + + return 0; +} + +static int hci_h4p_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct hci_h4p_info *info; + int err = 0; + + BT_DBG("dev %p, skb %p", hdev, skb); + + info = hci_get_drvdata(hdev); + + if (!test_bit(HCI_RUNNING, &hdev->flags)) { + dev_warn(info->dev, "Frame for non-running device\n"); + return -EIO; + } + + switch (bt_cb(skb)->pkt_type) { + case HCI_COMMAND_PKT: + hdev->stat.cmd_tx++; + break; + case HCI_ACLDATA_PKT: + hdev->stat.acl_tx++; + break; + case HCI_SCODATA_PKT: + hdev->stat.sco_tx++; + break; + } + + /* Push frame type to skb */ + *skb_push(skb, 1) = (bt_cb(skb)->pkt_type); + /* We should allways send word aligned data to h4+ devices */ + if (skb->len % 2) { + err = skb_pad(skb, 1); + if (!err) + *skb_put(skb, 1) = 0x00; + } + if (err) + return err; + + skb_queue_tail(&info->txq, skb); + hci_h4p_enable_tx(info); + + return 0; +} + +static ssize_t hci_h4p_store_bdaddr(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hci_h4p_info *info = dev_get_drvdata(dev); + unsigned int bdaddr[6]; + int ret, i; + + ret = sscanf(buf, "%2x:%2x:%2x:%2x:%2x:%2x\n", + &bdaddr[0], &bdaddr[1], &bdaddr[2], + &bdaddr[3], &bdaddr[4], &bdaddr[5]); + + if (ret != 6) + return -EINVAL; + + for (i = 0; i < 6; i++) { + if (bdaddr[i] > 0xff) + return -EINVAL; + info->bd_addr[i] = bdaddr[i] & 0xff; + } + + return count; +} + +static ssize_t hci_h4p_show_bdaddr(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hci_h4p_info *info = dev_get_drvdata(dev); + + return sprintf(buf, "%pMR\n", info->bd_addr); +} + +static DEVICE_ATTR(bdaddr, S_IRUGO | S_IWUSR, hci_h4p_show_bdaddr, + hci_h4p_store_bdaddr); + +static int hci_h4p_sysfs_create_files(struct device *dev) +{ + return device_create_file(dev, &dev_attr_bdaddr); +} + +static void hci_h4p_sysfs_remove_files(struct device *dev) +{ + device_remove_file(dev, &dev_attr_bdaddr); +} + +static int hci_h4p_register_hdev(struct hci_h4p_info *info) +{ + struct hci_dev *hdev; + + /* Initialize and register HCI device */ + + hdev = hci_alloc_dev(); + if (!hdev) { + dev_err(info->dev, "Can't allocate memory for device\n"); + return -ENOMEM; + } + info->hdev = hdev; + + hdev->bus = HCI_UART; + hci_set_drvdata(hdev, info); + + hdev->open = hci_h4p_hci_open; + hdev->close = hci_h4p_hci_close; + hdev->flush = hci_h4p_hci_flush; + hdev->send = hci_h4p_hci_send_frame; + set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); + + SET_HCIDEV_DEV(hdev, info->dev); + + if (hci_h4p_sysfs_create_files(info->dev) < 0) { + dev_err(info->dev, "failed to create sysfs files\n"); + goto free; + } + + if (hci_register_dev(hdev) >= 0) + return 0; + + dev_err(info->dev, "hci_register failed %s.\n", hdev->name); + hci_h4p_sysfs_remove_files(info->dev); +free: + hci_free_dev(info->hdev); + return -ENODEV; +} + +static int hci_h4p_probe(struct platform_device *pdev) +{ + struct hci_h4p_platform_data *bt_plat_data; + struct hci_h4p_info *info; + int err; + + dev_info(&pdev->dev, "Registering HCI H4P device\n"); + info = devm_kzalloc(&pdev->dev, sizeof(struct hci_h4p_info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->dev = &pdev->dev; + info->tx_enabled = 1; + info->rx_enabled = 1; + spin_lock_init(&info->lock); + spin_lock_init(&info->clocks_lock); + skb_queue_head_init(&info->txq); + + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Could not get Bluetooth config data\n"); + return -ENODATA; + } + + bt_plat_data = pdev->dev.platform_data; + info->chip_type = bt_plat_data->chip_type; + info->bt_wakeup_gpio = bt_plat_data->bt_wakeup_gpio; + info->host_wakeup_gpio = bt_plat_data->host_wakeup_gpio; + info->reset_gpio = bt_plat_data->reset_gpio; + info->reset_gpio_shared = bt_plat_data->reset_gpio_shared; + info->bt_sysclk = bt_plat_data->bt_sysclk; + + BT_DBG("RESET gpio: %d", info->reset_gpio); + BT_DBG("BTWU gpio: %d", info->bt_wakeup_gpio); + BT_DBG("HOSTWU gpio: %d", info->host_wakeup_gpio); + BT_DBG("sysclk: %d", info->bt_sysclk); + + init_completion(&info->test_completion); + complete_all(&info->test_completion); + + if (!info->reset_gpio_shared) { + err = devm_gpio_request_one(&pdev->dev, info->reset_gpio, + GPIOF_OUT_INIT_LOW, "bt_reset"); + if (err < 0) { + dev_err(&pdev->dev, "Cannot get GPIO line %d\n", + info->reset_gpio); + return err; + } + } + + err = devm_gpio_request_one(&pdev->dev, info->bt_wakeup_gpio, + GPIOF_OUT_INIT_LOW, "bt_wakeup"); + + if (err < 0) { + dev_err(info->dev, "Cannot get GPIO line 0x%d", + info->bt_wakeup_gpio); + return err; + } + + err = devm_gpio_request_one(&pdev->dev, info->host_wakeup_gpio, + GPIOF_DIR_IN, "host_wakeup"); + if (err < 0) { + dev_err(info->dev, "Cannot get GPIO line %d", + info->host_wakeup_gpio); + return err; + } + + info->irq = bt_plat_data->uart_irq; + info->uart_base = devm_ioremap(&pdev->dev, bt_plat_data->uart_base, SZ_2K); + info->uart_iclk = devm_clk_get(&pdev->dev, bt_plat_data->uart_iclk); + info->uart_fclk = devm_clk_get(&pdev->dev, bt_plat_data->uart_fclk); + + err = devm_request_irq(&pdev->dev, info->irq, hci_h4p_interrupt, IRQF_DISABLED, + "hci_h4p", info); + if (err < 0) { + dev_err(info->dev, "hci_h4p: unable to get IRQ %d\n", info->irq); + return err; + } + + err = devm_request_irq(&pdev->dev, gpio_to_irq(info->host_wakeup_gpio), + hci_h4p_wakeup_interrupt, IRQF_TRIGGER_FALLING | + IRQF_TRIGGER_RISING | IRQF_DISABLED, + "hci_h4p_wkup", info); + if (err < 0) { + dev_err(info->dev, "hci_h4p: unable to get wakeup IRQ %d\n", + gpio_to_irq(info->host_wakeup_gpio)); + return err; + } + + err = irq_set_irq_wake(gpio_to_irq(info->host_wakeup_gpio), 1); + if (err < 0) { + dev_err(info->dev, "hci_h4p: unable to set wakeup for IRQ %d\n", + gpio_to_irq(info->host_wakeup_gpio)); + return err; + } + + init_timer_deferrable(&info->lazy_release); + info->lazy_release.function = hci_h4p_lazy_clock_release; + info->lazy_release.data = (unsigned long)info; + hci_h4p_set_clk(info, &info->tx_clocks_en, 1); + err = hci_h4p_reset_uart(info); + if (err < 0) + return err; + gpio_set_value(info->reset_gpio, 0); + hci_h4p_set_clk(info, &info->tx_clocks_en, 0); + + platform_set_drvdata(pdev, info); + + if (hci_h4p_register_hdev(info) < 0) { + dev_err(info->dev, "failed to register hci_h4p hci device\n"); + return -EINVAL; + } + + return 0; +} + +static int hci_h4p_remove(struct platform_device *pdev) +{ + struct hci_h4p_info *info; + + info = platform_get_drvdata(pdev); + + hci_h4p_sysfs_remove_files(info->dev); + hci_h4p_hci_close(info->hdev); + hci_unregister_dev(info->hdev); + hci_free_dev(info->hdev); + + return 0; +} + +static struct platform_driver hci_h4p_driver = { + .probe = hci_h4p_probe, + .remove = hci_h4p_remove, + .driver = { + .name = "hci_h4p", + }, +}; + +module_platform_driver(hci_h4p_driver); + +MODULE_ALIAS("platform:hci_h4p"); +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia extensions"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Ville Tervo"); +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE); +MODULE_FIRMWARE(FW_NAME_TI1271_LE); +MODULE_FIRMWARE(FW_NAME_TI1271); +MODULE_FIRMWARE(FW_NAME_BCM2048); +MODULE_FIRMWARE(FW_NAME_CSR); diff --git a/drivers/staging/nokia_h4p/nokia_fw-bcm.c b/drivers/staging/nokia_h4p/nokia_fw-bcm.c new file mode 100644 index 000000000000..e8912bfc0a91 --- /dev/null +++ b/drivers/staging/nokia_h4p/nokia_fw-bcm.c @@ -0,0 +1,147 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2005-2008 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include +#include + +#include "hci_h4p.h" + +static int hci_h4p_bcm_set_bdaddr(struct hci_h4p_info *info, struct sk_buff *skb) +{ + int i; + static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; + int not_valid; + + not_valid = 1; + for (i = 0; i < 6; i++) { + if (info->bd_addr[i] != 0x00) { + not_valid = 0; + break; + } + } + + if (not_valid) { + dev_info(info->dev, "Valid bluetooth address not found, setting some random\n"); + /* When address is not valid, use some random but Nokia MAC */ + memcpy(info->bd_addr, nokia_oui, 3); + get_random_bytes(info->bd_addr + 3, 3); + } + + for (i = 0; i < 6; i++) + skb->data[9 - i] = info->bd_addr[i]; + + return 0; +} + +void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) +{ + struct sk_buff *fw_skb; + int err; + unsigned long flags; + + if (skb->data[5] != 0x00) { + dev_err(info->dev, "Firmware sending command failed 0x%.2x\n", + skb->data[5]); + info->fw_error = -EPROTO; + } + + kfree_skb(skb); + + fw_skb = skb_dequeue(info->fw_q); + if (fw_skb == NULL || info->fw_error) { + complete(&info->fw_completion); + return; + } + + if (fw_skb->data[1] == 0x01 && fw_skb->data[2] == 0xfc && fw_skb->len >= 10) { + BT_DBG("Setting bluetooth address"); + err = hci_h4p_bcm_set_bdaddr(info, fw_skb); + if (err < 0) { + kfree_skb(fw_skb); + info->fw_error = err; + complete(&info->fw_completion); + return; + } + } + + skb_queue_tail(&info->txq, fw_skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); +} + + +int hci_h4p_bcm_send_fw(struct hci_h4p_info *info, + struct sk_buff_head *fw_queue) +{ + struct sk_buff *skb; + unsigned long flags, time; + + info->fw_error = 0; + + BT_DBG("Sending firmware"); + + time = jiffies; + + info->fw_q = fw_queue; + skb = skb_dequeue(fw_queue); + if (!skb) + return -ENODATA; + + BT_DBG("Sending commands"); + + /* + * Disable smart-idle as UART TX interrupts + * are not wake-up capable + */ + hci_h4p_smart_idle(info, 0); + + /* Check if this is bd_address packet */ + init_completion(&info->fw_completion); + skb_queue_tail(&info->txq, skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); + + if (!wait_for_completion_timeout(&info->fw_completion, + msecs_to_jiffies(2000))) { + dev_err(info->dev, "No reply to fw command\n"); + return -ETIMEDOUT; + } + + if (info->fw_error) { + dev_err(info->dev, "FW error\n"); + return -EPROTO; + } + + BT_DBG("Firmware sent in %d msecs", + jiffies_to_msecs(jiffies-time)); + + hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS); + hci_h4p_set_rts(info, 0); + hci_h4p_change_speed(info, BC4_MAX_BAUD_RATE); + hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_RTS); + + return 0; +} diff --git a/drivers/staging/nokia_h4p/nokia_fw-csr.c b/drivers/staging/nokia_h4p/nokia_fw-csr.c new file mode 100644 index 000000000000..e39c4a31a879 --- /dev/null +++ b/drivers/staging/nokia_h4p/nokia_fw-csr.c @@ -0,0 +1,150 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2005-2008 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include +#include + +#include "hci_h4p.h" + +void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) +{ + /* Check if this is fw packet */ + if (skb->data[0] != 0xff) { + hci_recv_frame(info->hdev, skb); + return; + } + + if (skb->data[11] || skb->data[12]) { + dev_err(info->dev, "Firmware sending command failed\n"); + info->fw_error = -EPROTO; + } + + kfree_skb(skb); + complete(&info->fw_completion); +} + +int hci_h4p_bc4_send_fw(struct hci_h4p_info *info, + struct sk_buff_head *fw_queue) +{ + static const u8 nokia_oui[3] = {0x00, 0x19, 0x4F}; + struct sk_buff *skb; + unsigned int offset; + int retries, count, i, not_valid; + unsigned long flags; + + info->fw_error = 0; + + BT_DBG("Sending firmware"); + skb = skb_dequeue(fw_queue); + + if (!skb) + return -ENOMSG; + + /* Check if this is bd_address packet */ + if (skb->data[15] == 0x01 && skb->data[16] == 0x00) { + offset = 21; + skb->data[offset + 1] = 0x00; + skb->data[offset + 5] = 0x00; + + not_valid = 1; + for (i = 0; i < 6; i++) { + if (info->bd_addr[i] != 0x00) { + not_valid = 0; + break; + } + } + + if (not_valid) { + dev_info(info->dev, "Valid bluetooth address not found," + " setting some random\n"); + /* When address is not valid, use some random */ + memcpy(info->bd_addr, nokia_oui, 3); + get_random_bytes(info->bd_addr + 3, 3); + } + + skb->data[offset + 7] = info->bd_addr[0]; + skb->data[offset + 6] = info->bd_addr[1]; + skb->data[offset + 4] = info->bd_addr[2]; + skb->data[offset + 0] = info->bd_addr[3]; + skb->data[offset + 3] = info->bd_addr[4]; + skb->data[offset + 2] = info->bd_addr[5]; + } + + for (count = 1; ; count++) { + BT_DBG("Sending firmware command %d", count); + init_completion(&info->fw_completion); + skb_queue_tail(&info->txq, skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); + + skb = skb_dequeue(fw_queue); + if (!skb) + break; + + if (!wait_for_completion_timeout(&info->fw_completion, + msecs_to_jiffies(1000))) { + dev_err(info->dev, "No reply to fw command\n"); + return -ETIMEDOUT; + } + + if (info->fw_error) { + dev_err(info->dev, "FW error\n"); + return -EPROTO; + } + }; + + /* Wait for chip warm reset */ + retries = 100; + while ((!skb_queue_empty(&info->txq) || + !(hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT)) && + retries--) { + msleep(10); + } + if (!retries) { + dev_err(info->dev, "Transmitter not empty\n"); + return -ETIMEDOUT; + } + + hci_h4p_change_speed(info, BC4_MAX_BAUD_RATE); + + if (hci_h4p_wait_for_cts(info, 1, 100)) { + dev_err(info->dev, "cts didn't deassert after final speed\n"); + return -ETIMEDOUT; + } + + retries = 100; + do { + init_completion(&info->init_completion); + hci_h4p_send_alive_packet(info); + retries--; + } while (!wait_for_completion_timeout(&info->init_completion, 100) && + retries > 0); + + if (!retries) { + dev_err(info->dev, "No alive reply after speed change\n"); + return -ETIMEDOUT; + } + + return 0; +} diff --git a/drivers/staging/nokia_h4p/nokia_fw-ti1273.c b/drivers/staging/nokia_h4p/nokia_fw-ti1273.c new file mode 100644 index 000000000000..f5500f71c839 --- /dev/null +++ b/drivers/staging/nokia_h4p/nokia_fw-ti1273.c @@ -0,0 +1,110 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2009 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include +#include + +#include "hci_h4p.h" + +static struct sk_buff_head *fw_q; + +void hci_h4p_ti1273_parse_fw_event(struct hci_h4p_info *info, + struct sk_buff *skb) +{ + struct sk_buff *fw_skb; + unsigned long flags; + + if (skb->data[5] != 0x00) { + dev_err(info->dev, "Firmware sending command failed 0x%.2x\n", + skb->data[5]); + info->fw_error = -EPROTO; + } + + kfree_skb(skb); + + fw_skb = skb_dequeue(fw_q); + if (fw_skb == NULL || info->fw_error) { + complete(&info->fw_completion); + return; + } + + skb_queue_tail(&info->txq, fw_skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); +} + + +int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info, + struct sk_buff_head *fw_queue) +{ + struct sk_buff *skb; + unsigned long flags, time; + + info->fw_error = 0; + + BT_DBG("Sending firmware"); + + time = jiffies; + + fw_q = fw_queue; + skb = skb_dequeue(fw_queue); + if (!skb) + return -ENODATA; + + BT_DBG("Sending commands"); + /* Check if this is bd_address packet */ + init_completion(&info->fw_completion); + hci_h4p_smart_idle(info, 0); + skb_queue_tail(&info->txq, skb); + spin_lock_irqsave(&info->lock, flags); + hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | + UART_IER_THRI); + spin_unlock_irqrestore(&info->lock, flags); + + if (!wait_for_completion_timeout(&info->fw_completion, + msecs_to_jiffies(2000))) { + dev_err(info->dev, "No reply to fw command\n"); + return -ETIMEDOUT; + } + + if (info->fw_error) { + dev_err(info->dev, "FW error\n"); + return -EPROTO; + } + + BT_DBG("Firmware sent in %d msecs", + jiffies_to_msecs(jiffies-time)); + + hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS); + hci_h4p_set_rts(info, 0); + hci_h4p_change_speed(info, BC4_MAX_BAUD_RATE); + if (hci_h4p_wait_for_cts(info, 1, 100)) { + dev_err(info->dev, + "cts didn't go down after final speed change\n"); + return -ETIMEDOUT; + } + hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_RTS); + + return 0; +} diff --git a/drivers/staging/nokia_h4p/nokia_fw.c b/drivers/staging/nokia_h4p/nokia_fw.c new file mode 100644 index 000000000000..cfea61cd59e9 --- /dev/null +++ b/drivers/staging/nokia_h4p/nokia_fw.c @@ -0,0 +1,195 @@ +/* + * This file is part of hci_h4p bluetooth driver + * + * Copyright (C) 2005, 2006 Nokia Corporation. + * + * Contact: Ville Tervo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include +#include + +#include + +#include "hci_h4p.h" + +static int fw_pos; + +/* Firmware handling */ +static int hci_h4p_open_firmware(struct hci_h4p_info *info, + const struct firmware **fw_entry) +{ + int err; + + fw_pos = 0; + BT_DBG("Opening firmware man_id 0x%.2x ver_id 0x%.2x", + info->man_id, info->ver_id); + switch (info->man_id) { + case H4P_ID_TI1271: + switch (info->ver_id) { + case 0xe1: + err = request_firmware(fw_entry, FW_NAME_TI1271_PRELE, + info->dev); + break; + case 0xd1: + case 0xf1: + err = request_firmware(fw_entry, FW_NAME_TI1271_LE, + info->dev); + break; + default: + err = request_firmware(fw_entry, FW_NAME_TI1271, + info->dev); + } + break; + case H4P_ID_CSR: + err = request_firmware(fw_entry, FW_NAME_CSR, info->dev); + break; + case H4P_ID_BCM2048: + err = request_firmware(fw_entry, FW_NAME_BCM2048, info->dev); + break; + default: + dev_err(info->dev, "Invalid chip type\n"); + *fw_entry = NULL; + err = -EINVAL; + } + + return err; +} + +static void hci_h4p_close_firmware(const struct firmware *fw_entry) +{ + release_firmware(fw_entry); +} + +/* Read fw. Return length of the command. If no more commands in + * fw 0 is returned. In error case return value is negative. + */ +static int hci_h4p_read_fw_cmd(struct hci_h4p_info *info, struct sk_buff **skb, + const struct firmware *fw_entry, gfp_t how) +{ + unsigned int cmd_len; + + if (fw_pos >= fw_entry->size) + return 0; + + if (fw_pos + 2 > fw_entry->size) { + dev_err(info->dev, "Corrupted firmware image 1\n"); + return -EMSGSIZE; + } + + cmd_len = fw_entry->data[fw_pos++]; + cmd_len += fw_entry->data[fw_pos++] << 8; + if (cmd_len == 0) + return 0; + + if (fw_pos + cmd_len > fw_entry->size) { + dev_err(info->dev, "Corrupted firmware image 2\n"); + return -EMSGSIZE; + } + + *skb = bt_skb_alloc(cmd_len, how); + if (!*skb) { + dev_err(info->dev, "Cannot reserve memory for buffer\n"); + return -ENOMEM; + } + memcpy(skb_put(*skb, cmd_len), &fw_entry->data[fw_pos], cmd_len); + + fw_pos += cmd_len; + + return (*skb)->len; +} + +int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue) +{ + const struct firmware *fw_entry = NULL; + struct sk_buff *skb = NULL; + int err; + + err = hci_h4p_open_firmware(info, &fw_entry); + if (err < 0 || !fw_entry) + goto err_clean; + + while ((err = hci_h4p_read_fw_cmd(info, &skb, fw_entry, GFP_KERNEL))) { + if (err < 0 || !skb) + goto err_clean; + + skb_queue_tail(fw_queue, skb); + } + + /* Chip detection code does neg and alive stuff + * discard two first skbs */ + skb = skb_dequeue(fw_queue); + if (!skb) { + err = -EMSGSIZE; + goto err_clean; + } + kfree_skb(skb); + skb = skb_dequeue(fw_queue); + if (!skb) { + err = -EMSGSIZE; + goto err_clean; + } + kfree_skb(skb); + +err_clean: + hci_h4p_close_firmware(fw_entry); + return err; +} + +int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue) +{ + int err; + + switch (info->man_id) { + case H4P_ID_CSR: + err = hci_h4p_bc4_send_fw(info, fw_queue); + break; + case H4P_ID_TI1271: + err = hci_h4p_ti1273_send_fw(info, fw_queue); + break; + case H4P_ID_BCM2048: + err = hci_h4p_bcm_send_fw(info, fw_queue); + break; + default: + dev_err(info->dev, "Don't know how to send firmware\n"); + err = -EINVAL; + } + + return err; +} + +void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) +{ + switch (info->man_id) { + case H4P_ID_CSR: + hci_h4p_bc4_parse_fw_event(info, skb); + break; + case H4P_ID_TI1271: + hci_h4p_ti1273_parse_fw_event(info, skb); + break; + case H4P_ID_BCM2048: + hci_h4p_bcm_parse_fw_event(info, skb); + break; + default: + dev_err(info->dev, "Don't know how to parse fw event\n"); + info->fw_error = -EINVAL; + } + + return; +} diff --git a/drivers/staging/nokia_h4p/nokia_uart.c b/drivers/staging/nokia_h4p/nokia_uart.c new file mode 100644 index 000000000000..0fb57de4b750 --- /dev/null +++ b/drivers/staging/nokia_h4p/nokia_uart.c @@ -0,0 +1,199 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2005, 2006 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include +#include + +#include + +#include "hci_h4p.h" + +inline void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val) +{ + __raw_writeb(val, info->uart_base + (offset << 2)); +} + +inline u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset) +{ + return __raw_readb(info->uart_base + (offset << 2)); +} + +void hci_h4p_set_rts(struct hci_h4p_info *info, int active) +{ + u8 b; + + b = hci_h4p_inb(info, UART_MCR); + if (active) + b |= UART_MCR_RTS; + else + b &= ~UART_MCR_RTS; + hci_h4p_outb(info, UART_MCR, b); +} + +int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, + int timeout_ms) +{ + unsigned long timeout; + int state; + + timeout = jiffies + msecs_to_jiffies(timeout_ms); + for (;;) { + state = hci_h4p_inb(info, UART_MSR) & UART_MSR_CTS; + if (active) { + if (state) + return 0; + } else { + if (!state) + return 0; + } + if (time_after(jiffies, timeout)) + return -ETIMEDOUT; + msleep(1); + } +} + +void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which) +{ + u8 lcr, b; + + lcr = hci_h4p_inb(info, UART_LCR); + hci_h4p_outb(info, UART_LCR, 0xbf); + b = hci_h4p_inb(info, UART_EFR); + if (on) + b |= which; + else + b &= ~which; + hci_h4p_outb(info, UART_EFR, b); + hci_h4p_outb(info, UART_LCR, lcr); +} + +void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which) +{ + unsigned long flags; + + spin_lock_irqsave(&info->lock, flags); + __hci_h4p_set_auto_ctsrts(info, on, which); + spin_unlock_irqrestore(&info->lock, flags); +} + +void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed) +{ + unsigned int divisor; + u8 lcr, mdr1; + + BT_DBG("Setting speed %lu", speed); + + if (speed >= 460800) { + divisor = UART_CLOCK / 13 / speed; + mdr1 = 3; + } else { + divisor = UART_CLOCK / 16 / speed; + mdr1 = 0; + } + + /* Make sure UART mode is disabled */ + hci_h4p_outb(info, UART_OMAP_MDR1, 7); + + lcr = hci_h4p_inb(info, UART_LCR); + hci_h4p_outb(info, UART_LCR, UART_LCR_DLAB); /* Set DLAB */ + hci_h4p_outb(info, UART_DLL, divisor & 0xff); /* Set speed */ + hci_h4p_outb(info, UART_DLM, divisor >> 8); + hci_h4p_outb(info, UART_LCR, lcr); + + /* Make sure UART mode is enabled */ + hci_h4p_outb(info, UART_OMAP_MDR1, mdr1); +} + +int hci_h4p_reset_uart(struct hci_h4p_info *info) +{ + int count = 0; + + /* Reset the UART */ + hci_h4p_outb(info, UART_OMAP_SYSC, UART_SYSC_OMAP_RESET); + while (!(hci_h4p_inb(info, UART_OMAP_SYSS) & UART_SYSS_RESETDONE)) { + if (count++ > 100) { + dev_err(info->dev, "hci_h4p: UART reset timeout\n"); + return -ENODEV; + } + udelay(1); + } + + return 0; +} + +void hci_h4p_store_regs(struct hci_h4p_info *info) +{ + u16 lcr = 0; + + lcr = hci_h4p_inb(info, UART_LCR); + hci_h4p_outb(info, UART_LCR, 0xBF); + info->dll = hci_h4p_inb(info, UART_DLL); + info->dlh = hci_h4p_inb(info, UART_DLM); + info->efr = hci_h4p_inb(info, UART_EFR); + hci_h4p_outb(info, UART_LCR, lcr); + info->mdr1 = hci_h4p_inb(info, UART_OMAP_MDR1); + info->ier = hci_h4p_inb(info, UART_IER); +} + +void hci_h4p_restore_regs(struct hci_h4p_info *info) +{ + u16 lcr = 0; + + hci_h4p_init_uart(info); + + hci_h4p_outb(info, UART_OMAP_MDR1, 7); + lcr = hci_h4p_inb(info, UART_LCR); + hci_h4p_outb(info, UART_LCR, 0xBF); + hci_h4p_outb(info, UART_DLL, info->dll); /* Set speed */ + hci_h4p_outb(info, UART_DLM, info->dlh); + hci_h4p_outb(info, UART_EFR, info->efr); + hci_h4p_outb(info, UART_LCR, lcr); + hci_h4p_outb(info, UART_OMAP_MDR1, info->mdr1); + hci_h4p_outb(info, UART_IER, info->ier); +} + +void hci_h4p_init_uart(struct hci_h4p_info *info) +{ + u8 mcr, efr; + + /* Enable and setup FIFO */ + hci_h4p_outb(info, UART_OMAP_MDR1, 0x00); + + hci_h4p_outb(info, UART_LCR, 0xbf); + efr = hci_h4p_inb(info, UART_EFR); + hci_h4p_outb(info, UART_EFR, UART_EFR_ECB); + hci_h4p_outb(info, UART_LCR, UART_LCR_DLAB); + mcr = hci_h4p_inb(info, UART_MCR); + hci_h4p_outb(info, UART_MCR, UART_MCR_TCRTLR); + hci_h4p_outb(info, UART_FCR, UART_FCR_ENABLE_FIFO | + UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | + (3 << 6) | (0 << 4)); + hci_h4p_outb(info, UART_LCR, 0xbf); + hci_h4p_outb(info, UART_TI752_TLR, 0xed); + hci_h4p_outb(info, UART_TI752_TCR, 0xef); + hci_h4p_outb(info, UART_EFR, efr); + hci_h4p_outb(info, UART_LCR, UART_LCR_DLAB); + hci_h4p_outb(info, UART_MCR, 0x00); + hci_h4p_outb(info, UART_LCR, UART_LCR_WLEN8); + hci_h4p_outb(info, UART_IER, UART_IER_RDI); + hci_h4p_outb(info, UART_OMAP_SYSC, (1 << 0) | (1 << 2) | (2 << 3)); +} diff --git a/include/linux/platform_data/bt-nokia-h4p.h b/include/linux/platform_data/bt-nokia-h4p.h new file mode 100644 index 000000000000..30d169dfadf3 --- /dev/null +++ b/include/linux/platform_data/bt-nokia-h4p.h @@ -0,0 +1,38 @@ +/* + * This file is part of Nokia H4P bluetooth driver + * + * Copyright (C) 2010 Nokia 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. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + + +/** + * struct hci_h4p_platform data - hci_h4p Platform data structure + */ +struct hci_h4p_platform_data { + int chip_type; + int bt_sysclk; + unsigned int bt_wakeup_gpio; + unsigned int host_wakeup_gpio; + unsigned int reset_gpio; + int reset_gpio_shared; + unsigned int uart_irq; + phys_addr_t uart_base; + const char *uart_iclk; + const char *uart_fclk; + void (*set_pm_limits)(struct device *dev, bool set); +}; From 388abdac58ba2d195aadaee27170c1e54943777f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 23 Jan 2014 11:24:27 +0300 Subject: [PATCH 0059/1375] staging: cxt1e1: cleanup mfg_template[] a bit 1) Make it static. 2) Change it to u8 data instead of short. 3) This means we can memcpy() it to the correct location instead of using a for loop. 4) With memcpy() we can use the union member we want directly instead of copying to the generic .bytes union member. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index 137b63cb5537..78cc1709ebdb 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -90,7 +90,7 @@ static int ByteReverseBuilt = FALSE; *------------------------------------------------------------------------ */ -short mfg_template[sizeof (FLD_TYPE2)] = +static u8 mfg_template[sizeof(FLD_TYPE2)] = { PROM_FORMAT_TYPE2, /* type; */ 0x00, 0x1A, /* length[2]; */ @@ -491,13 +491,11 @@ pmc_init_seeprom (u_int32_t addr, u_int32_t serialNum) PROMFORMAT buffer; /* Memory image of structure */ u_int32_t crc; /* CRC of structure */ time_t createTime; - int i; createTime = get_seconds (); /* use template data */ - for (i = 0; i < sizeof (FLD_TYPE2); ++i) - buffer.bytes[i] = mfg_template[i]; + memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2)); /* Update serial number field in buffer */ pmcSetBuffValue (&buffer.fldType2.Serial[3], serialNum, 3); From 19ca44bdc7bf84a324344836367526a436a6e482 Mon Sep 17 00:00:00 2001 From: Rashika Kheria Date: Fri, 24 Jan 2014 04:14:00 +0530 Subject: [PATCH 0060/1375] drivers: staging: Mark functions as static and remove unused function in bpctl_mod.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark functions as static in bpctl_mod.c because they are not used outside this file. Remove unused function from bpctl_mod.c. This also eliminates the following warnings from bpctl_mod.c: drivers/staging/silicom/bpctl_mod.c:1507:6: warning: no previous prototype for ‘send_bypass_clear_pulse’ [-Wmissing-prototypes] drivers/staging/silicom/bpctl_mod.c:1762:5: warning: no previous prototype for ‘cmnd_on’ [-Wmissing-prototypes] drivers/staging/silicom/bpctl_mod.c:1779:5: warning: no previous prototype for ‘cmnd_off’ [-Wmissing-prototypes] ... Signed-off-by: Rashika Kheria Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 584 ++++++---------------------- 1 file changed, 126 insertions(+), 458 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 20325f53328e..00b3c5157ea1 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -1502,7 +1502,8 @@ static int send_wdt_pulse(struct bpctl_dev *pbpctl_dev) return 0; } -void send_bypass_clear_pulse(struct bpctl_dev *pbpctl_dev, unsigned int value) +static void send_bypass_clear_pulse(struct bpctl_dev *pbpctl_dev, + unsigned int value) { uint32_t ctrl_ext = 0; @@ -1757,7 +1758,7 @@ static int wdt_pulse_int(struct bpctl_dev *pbpctl_dev) /*************************************/ /* CMND_ON 0x4 (100)*/ -int cmnd_on(struct bpctl_dev *pbpctl_dev) +static int cmnd_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1774,7 +1775,7 @@ int cmnd_on(struct bpctl_dev *pbpctl_dev) } /* CMND_OFF 0x2 (10)*/ -int cmnd_off(struct bpctl_dev *pbpctl_dev) +static int cmnd_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1792,7 +1793,7 @@ int cmnd_off(struct bpctl_dev *pbpctl_dev) } /* BYPASS_ON (0xa)*/ -int bypass_on(struct bpctl_dev *pbpctl_dev) +static int bypass_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1813,7 +1814,7 @@ int bypass_on(struct bpctl_dev *pbpctl_dev) } /* BYPASS_OFF (0x8 111)*/ -int bypass_off(struct bpctl_dev *pbpctl_dev) +static int bypass_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1836,7 +1837,7 @@ int bypass_off(struct bpctl_dev *pbpctl_dev) } /* TAP_OFF (0x9)*/ -int tap_off(struct bpctl_dev *pbpctl_dev) +static int tap_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if ((pbpctl_dev->bp_caps & TAP_CAP) @@ -1849,7 +1850,7 @@ int tap_off(struct bpctl_dev *pbpctl_dev) } /* TAP_ON (0xb)*/ -int tap_on(struct bpctl_dev *pbpctl_dev) +static int tap_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if ((pbpctl_dev->bp_caps & TAP_CAP) @@ -1862,7 +1863,7 @@ int tap_on(struct bpctl_dev *pbpctl_dev) } /* DISC_OFF (0x9)*/ -int disc_off(struct bpctl_dev *pbpctl_dev) +static int disc_off(struct bpctl_dev *pbpctl_dev) { int ret = 0; if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { @@ -1874,7 +1875,7 @@ int disc_off(struct bpctl_dev *pbpctl_dev) } /* DISC_ON (0xb)*/ -int disc_on(struct bpctl_dev *pbpctl_dev) +static int disc_on(struct bpctl_dev *pbpctl_dev) { int ret = 0; if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { @@ -1885,58 +1886,8 @@ int disc_on(struct bpctl_dev *pbpctl_dev) return ret; } -/* DISC_PORT_ON */ -int disc_port_on(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - struct bpctl_dev *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_DISA); - else - write_data(pbpctl_dev_m, TX_DISB); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - -/* DISC_PORT_OFF */ -int disc_port_off(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - struct bpctl_dev *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_ENA); - else - write_data(pbpctl_dev_m, TX_ENB); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - /*TWO_PORT_LINK_HW_EN (0xe)*/ -int tpl_hw_on(struct bpctl_dev *pbpctl_dev) +static int tpl_hw_on(struct bpctl_dev *pbpctl_dev) { int ret = 0, ctrl = 0; struct bpctl_dev *pbpctl_dev_b = NULL; @@ -1964,7 +1915,7 @@ int tpl_hw_on(struct bpctl_dev *pbpctl_dev) } /*TWO_PORT_LINK_HW_DIS (0xc)*/ -int tpl_hw_off(struct bpctl_dev *pbpctl_dev) +static int tpl_hw_off(struct bpctl_dev *pbpctl_dev) { int ret = 0, ctrl = 0; struct bpctl_dev *pbpctl_dev_b = NULL; @@ -1990,7 +1941,7 @@ int tpl_hw_off(struct bpctl_dev *pbpctl_dev) } /* WDT_OFF (0x6 110)*/ -int wdt_off(struct bpctl_dev *pbpctl_dev) +static int wdt_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -2013,7 +1964,7 @@ int wdt_off(struct bpctl_dev *pbpctl_dev) static unsigned int wdt_val_array[] = { 1000, 1500, 2000, 3000, 4000, 8000, 16000, 32000, 0 }; -int wdt_on(struct bpctl_dev *pbpctl_dev, unsigned int timeout) +static int wdt_on(struct bpctl_dev *pbpctl_dev, unsigned int timeout) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -2065,7 +2016,7 @@ int wdt_on(struct bpctl_dev *pbpctl_dev, unsigned int timeout) return BP_NOT_CAP; } -void bp75_put_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) +static void bp75_put_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) { u32 swsm; @@ -2076,7 +2027,7 @@ void bp75_put_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) BPCTL_WRITE_REG(pbpctl_dev, SWSM, swsm); } -s32 bp75_get_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) +static s32 bp75_get_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) { u32 swsm; s32 ret_val = 0; @@ -2190,7 +2141,8 @@ static s32 bp75_acquire_phy(struct bpctl_dev *pbpctl_dev) return ret_val; } -s32 bp75_read_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, u16 *data) +static s32 bp75_read_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, + u16 *data) { u32 i, mdic = 0; s32 ret_val = 0; @@ -2223,7 +2175,8 @@ s32 bp75_read_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, u16 *data) return ret_val; } -s32 bp75_write_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, u16 data) +static s32 bp75_write_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, + u16 data) { u32 i, mdic = 0; s32 ret_val = 0; @@ -2534,7 +2487,7 @@ static int set_bp_force_link(struct bpctl_dev *pbpctl_dev, int tx_state) } /*RESET_CONT 0x20 */ -int reset_cont(struct bpctl_dev *pbpctl_dev) +static int reset_cont(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -2551,7 +2504,7 @@ int reset_cont(struct bpctl_dev *pbpctl_dev) } /*DIS_BYPASS_CAP 0x22 */ -int dis_bypass_cap(struct bpctl_dev *pbpctl_dev) +static int dis_bypass_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_DIS_CAP) { @@ -2570,7 +2523,7 @@ int dis_bypass_cap(struct bpctl_dev *pbpctl_dev) } /*EN_BYPASS_CAP 0x24 */ -int en_bypass_cap(struct bpctl_dev *pbpctl_dev) +static int en_bypass_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_DIS_CAP) { if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { @@ -2586,7 +2539,7 @@ int en_bypass_cap(struct bpctl_dev *pbpctl_dev) } /* BYPASS_STATE_PWRON 0x26*/ -int bypass_state_pwron(struct bpctl_dev *pbpctl_dev) +static int bypass_state_pwron(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { write_data(pbpctl_dev, BYPASS_STATE_PWRON); @@ -2600,7 +2553,7 @@ int bypass_state_pwron(struct bpctl_dev *pbpctl_dev) } /* NORMAL_STATE_PWRON 0x28*/ -int normal_state_pwron(struct bpctl_dev *pbpctl_dev) +static int normal_state_pwron(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) || (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP)) { @@ -2615,7 +2568,7 @@ int normal_state_pwron(struct bpctl_dev *pbpctl_dev) } /* BYPASS_STATE_PWROFF 0x27*/ -int bypass_state_pwroff(struct bpctl_dev *pbpctl_dev) +static int bypass_state_pwroff(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP) { write_data(pbpctl_dev, BYPASS_STATE_PWROFF); @@ -2626,7 +2579,7 @@ int bypass_state_pwroff(struct bpctl_dev *pbpctl_dev) } /* NORMAL_STATE_PWROFF 0x29*/ -int normal_state_pwroff(struct bpctl_dev *pbpctl_dev) +static int normal_state_pwroff(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) { write_data(pbpctl_dev, NORMAL_STATE_PWROFF); @@ -2637,7 +2590,7 @@ int normal_state_pwroff(struct bpctl_dev *pbpctl_dev) } /*TAP_STATE_PWRON 0x2a*/ -int tap_state_pwron(struct bpctl_dev *pbpctl_dev) +static int tap_state_pwron(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { write_data(pbpctl_dev, TAP_STATE_PWRON); @@ -2648,7 +2601,7 @@ int tap_state_pwron(struct bpctl_dev *pbpctl_dev) } /*DIS_TAP_CAP 0x2c*/ -int dis_tap_cap(struct bpctl_dev *pbpctl_dev) +static int dis_tap_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { write_data(pbpctl_dev, DIS_TAP_CAP); @@ -2659,7 +2612,7 @@ int dis_tap_cap(struct bpctl_dev *pbpctl_dev) } /*EN_TAP_CAP 0x2e*/ -int en_tap_cap(struct bpctl_dev *pbpctl_dev) +static int en_tap_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { write_data(pbpctl_dev, EN_TAP_CAP); @@ -2670,7 +2623,7 @@ int en_tap_cap(struct bpctl_dev *pbpctl_dev) } /*DISC_STATE_PWRON 0x2a*/ -int disc_state_pwron(struct bpctl_dev *pbpctl_dev) +static int disc_state_pwron(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { @@ -2683,7 +2636,7 @@ int disc_state_pwron(struct bpctl_dev *pbpctl_dev) } /*DIS_DISC_CAP 0x2c*/ -int dis_disc_cap(struct bpctl_dev *pbpctl_dev) +static int dis_disc_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { @@ -2695,60 +2648,8 @@ int dis_disc_cap(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -/*DISC_STATE_PWRON 0x2a*/ -int disc_port_state_pwron(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - struct bpctl_dev *pbpctl_dev_m; - - return BP_NOT_CAP; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_DISA_PWRUP); - else - write_data(pbpctl_dev_m, TX_DISB_PWRUP); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - -int normal_port_state_pwron(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - struct bpctl_dev *pbpctl_dev_m; - return BP_NOT_CAP; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_ENA_PWRUP); - else - write_data(pbpctl_dev_m, TX_ENB_PWRUP); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - /*EN_TAP_CAP 0x2e*/ -int en_disc_cap(struct bpctl_dev *pbpctl_dev) +static int en_disc_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { @@ -2760,7 +2661,7 @@ int en_disc_cap(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int std_nic_on(struct bpctl_dev *pbpctl_dev) +static int std_nic_on(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & STD_NIC_CAP) { @@ -2814,7 +2715,7 @@ int std_nic_on(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int std_nic_off(struct bpctl_dev *pbpctl_dev) +static int std_nic_off(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & STD_NIC_CAP) { @@ -2977,7 +2878,7 @@ static void wd_reset_timer(unsigned long param) } /*WAIT_AT_PWRUP 0x80 */ -int bp_wait_at_pwup_en(struct bpctl_dev *pbpctl_dev) +static int bp_wait_at_pwup_en(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -2992,7 +2893,7 @@ int bp_wait_at_pwup_en(struct bpctl_dev *pbpctl_dev) } /*DIS_WAIT_AT_PWRUP 0x81 */ -int bp_wait_at_pwup_dis(struct bpctl_dev *pbpctl_dev) +static int bp_wait_at_pwup_dis(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3009,7 +2910,7 @@ int bp_wait_at_pwup_dis(struct bpctl_dev *pbpctl_dev) /*EN_HW_RESET 0x82 */ -int bp_hw_reset_en(struct bpctl_dev *pbpctl_dev) +static int bp_hw_reset_en(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3025,7 +2926,7 @@ int bp_hw_reset_en(struct bpctl_dev *pbpctl_dev) /*DIS_HW_RESET 0x83 */ -int bp_hw_reset_dis(struct bpctl_dev *pbpctl_dev) +static int bp_hw_reset_dis(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3040,7 +2941,7 @@ int bp_hw_reset_dis(struct bpctl_dev *pbpctl_dev) } -int wdt_exp_mode(struct bpctl_dev *pbpctl_dev, int mode) +static int wdt_exp_mode(struct bpctl_dev *pbpctl_dev, int mode) { uint32_t status_reg = 0, status_reg1 = 0; @@ -3091,7 +2992,7 @@ int wdt_exp_mode(struct bpctl_dev *pbpctl_dev, int mode) return BP_NOT_CAP; } -int bypass_fw_ver(struct bpctl_dev *pbpctl_dev) +static int bypass_fw_ver(struct bpctl_dev *pbpctl_dev) { if (is_bypass_fn(pbpctl_dev)) return read_reg(pbpctl_dev, VER_REG_ADDR); @@ -3099,7 +3000,7 @@ int bypass_fw_ver(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bypass_sign_check(struct bpctl_dev *pbpctl_dev) +static int bypass_sign_check(struct bpctl_dev *pbpctl_dev) { if (is_bypass_fn(pbpctl_dev)) @@ -3210,7 +3111,7 @@ static int bp_force_link_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bypass_from_last_read(struct bpctl_dev *pbpctl_dev) +static int bypass_from_last_read(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; struct bpctl_dev *pbpctl_dev_b = NULL; @@ -3230,7 +3131,7 @@ int bypass_from_last_read(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bypass_status_clear(struct bpctl_dev *pbpctl_dev) +static int bypass_status_clear(struct bpctl_dev *pbpctl_dev) { struct bpctl_dev *pbpctl_dev_b = NULL; @@ -3244,7 +3145,7 @@ int bypass_status_clear(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bypass_flag_status(struct bpctl_dev *pbpctl_dev) +static int bypass_flag_status(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & BP_CAP)) { @@ -3257,7 +3158,7 @@ int bypass_flag_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bypass_flag_status_clear(struct bpctl_dev *pbpctl_dev) +static int bypass_flag_status_clear(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_CAP) { @@ -3272,7 +3173,7 @@ int bypass_flag_status_clear(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bypass_change_status(struct bpctl_dev *pbpctl_dev) +static int bypass_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -3291,18 +3192,6 @@ int bypass_change_status(struct bpctl_dev *pbpctl_dev) return ret; } -int bypass_off_status(struct bpctl_dev *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & BP_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - BYPASS_OFF_MASK) == BYPASS_OFF_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - static int bypass_status(struct bpctl_dev *pbpctl_dev) { u32 ctrl_ext = 0; @@ -3386,7 +3275,7 @@ static int bypass_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int default_pwron_status(struct bpctl_dev *pbpctl_dev) +static int default_pwron_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3418,7 +3307,7 @@ static int default_pwroff_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int dis_bypass_cap_status(struct bpctl_dev *pbpctl_dev) +static int dis_bypass_cap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_DIS_CAP) { @@ -3431,31 +3320,7 @@ int dis_bypass_cap_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int cmd_en_status(struct bpctl_dev *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - CMND_EN_MASK) == CMND_EN_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int wdt_en_status(struct bpctl_dev *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - WDT_EN_MASK) == WDT_EN_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int wdt_programmed(struct bpctl_dev *pbpctl_dev, int *timeout) +static int wdt_programmed(struct bpctl_dev *pbpctl_dev, int *timeout) { int ret = 0; if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -3481,40 +3346,7 @@ int wdt_programmed(struct bpctl_dev *pbpctl_dev, int *timeout) return ret; } -int bypass_support(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - ret = - ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & - BYPASS_SUPPORT_MASK) == - BYPASS_SUPPORT_MASK) ? 1 : 0); - } else if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - ret = 1; - } else - ret = BP_NOT_CAP; - return ret; -} - -int tap_support(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - ret = - ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & - TAP_SUPPORT_MASK) == TAP_SUPPORT_MASK) ? 1 : 0); - } else if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - ret = 0; - } else - ret = BP_NOT_CAP; - return ret; -} - -int normal_support(struct bpctl_dev *pbpctl_dev) +static int normal_support(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -3530,7 +3362,7 @@ int normal_support(struct bpctl_dev *pbpctl_dev) return ret; } -int get_bp_prod_caps(struct bpctl_dev *pbpctl_dev) +static int get_bp_prod_caps(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & SW_CTL_CAP) && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) @@ -3539,7 +3371,7 @@ int get_bp_prod_caps(struct bpctl_dev *pbpctl_dev) } -int tap_flag_status(struct bpctl_dev *pbpctl_dev) +static int tap_flag_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { @@ -3551,7 +3383,7 @@ int tap_flag_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int tap_flag_status_clear(struct bpctl_dev *pbpctl_dev) +static int tap_flag_status_clear(struct bpctl_dev *pbpctl_dev) { uint32_t status_reg = 0; if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { @@ -3565,7 +3397,7 @@ int tap_flag_status_clear(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int tap_change_status(struct bpctl_dev *pbpctl_dev) +static int tap_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { @@ -3582,17 +3414,7 @@ int tap_change_status(struct bpctl_dev *pbpctl_dev) return ret; } -int tap_off_status(struct bpctl_dev *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TAP_OFF_MASK) == TAP_OFF_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int tap_status(struct bpctl_dev *pbpctl_dev) +static int tap_status(struct bpctl_dev *pbpctl_dev) { u32 ctrl_ext = 0; @@ -3631,7 +3453,7 @@ int tap_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int default_pwron_tap_status(struct bpctl_dev *pbpctl_dev) +static int default_pwron_tap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) @@ -3642,7 +3464,7 @@ int default_pwron_tap_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int dis_tap_cap_status(struct bpctl_dev *pbpctl_dev) +static int dis_tap_cap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) @@ -3653,7 +3475,7 @@ int dis_tap_cap_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int disc_flag_status(struct bpctl_dev *pbpctl_dev) +static int disc_flag_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3665,7 +3487,7 @@ int disc_flag_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int disc_flag_status_clear(struct bpctl_dev *pbpctl_dev) +static int disc_flag_status_clear(struct bpctl_dev *pbpctl_dev) { uint32_t status_reg = 0; if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3679,7 +3501,7 @@ int disc_flag_status_clear(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int disc_change_status(struct bpctl_dev *pbpctl_dev) +static int disc_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3690,7 +3512,7 @@ int disc_change_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int disc_off_status(struct bpctl_dev *pbpctl_dev) +static int disc_off_status(struct bpctl_dev *pbpctl_dev) { struct bpctl_dev *pbpctl_dev_b = NULL; u32 ctrl_ext = 0; @@ -3786,7 +3608,7 @@ static int disc_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int default_pwron_disc_status(struct bpctl_dev *pbpctl_dev) +static int default_pwron_disc_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) @@ -3797,7 +3619,7 @@ int default_pwron_disc_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int dis_disc_cap_status(struct bpctl_dev *pbpctl_dev) +static int dis_disc_cap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DIS_DISC_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) @@ -3808,55 +3630,7 @@ int dis_disc_cap_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int disc_port_status(struct bpctl_dev *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - struct bpctl_dev *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) { - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TX_DISA_MASK) == TX_DISA_MASK) ? 1 : 0); - } else - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TX_DISB_MASK) == TX_DISB_MASK) ? 1 : 0); - - } - return ret; -} - -int default_pwron_disc_port_status(struct bpctl_dev *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - struct bpctl_dev *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - return ret; - /* return((((read_reg(pbpctl_dev,STATUS_TAP_REG_ADDR)) & TX_DISA_MASK)==TX_DISA_MASK)?1:0); */ - else - return ret; - /* return((((read_reg(pbpctl_dev,STATUS_TAP_REG_ADDR)) & TX_DISA_MASK)==TX_DISA_MASK)?1:0); */ - - } - return ret; -} - -int wdt_exp_mode_status(struct bpctl_dev *pbpctl_dev) +static int wdt_exp_mode_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { if (pbpctl_dev->bp_ext_ver <= PXG2BPI_VER) @@ -3879,7 +3653,7 @@ int wdt_exp_mode_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int tpl2_flag_status(struct bpctl_dev *pbpctl_dev) +static int tpl2_flag_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { @@ -3890,22 +3664,7 @@ int tpl2_flag_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int tpl_hw_status(struct bpctl_dev *pbpctl_dev) -{ - struct bpctl_dev *pbpctl_dev_b = NULL; - - pbpctl_dev_b = get_status_port_fn(pbpctl_dev); - if (!pbpctl_dev_b) - return BP_NOT_CAP; - - if (TPL_IF_SERIES(pbpctl_dev->subdevice)) - return (((BPCTL_READ_REG(pbpctl_dev, CTRL)) & - BPCTLI_CTRL_SWDPIN0) != 0 ? 1 : 0); - return BP_NOT_CAP; -} - - -int bp_wait_at_pwup_status(struct bpctl_dev *pbpctl_dev) +static int bp_wait_at_pwup_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) @@ -3916,7 +3675,7 @@ int bp_wait_at_pwup_status(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int bp_hw_reset_status(struct bpctl_dev *pbpctl_dev) +static int bp_hw_reset_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3930,7 +3689,7 @@ int bp_hw_reset_status(struct bpctl_dev *pbpctl_dev) } -int std_nic_status(struct bpctl_dev *pbpctl_dev) +static int std_nic_status(struct bpctl_dev *pbpctl_dev) { int status_val = 0; @@ -3978,7 +3737,7 @@ int std_nic_status(struct bpctl_dev *pbpctl_dev) /******************************************************/ /**************SW_INIT*********************************/ /******************************************************/ -void bypass_caps_init(struct bpctl_dev *pbpctl_dev) +static void bypass_caps_init(struct bpctl_dev *pbpctl_dev) { u_int32_t ctrl_ext = 0; struct bpctl_dev *pbpctl_dev_m = NULL; @@ -4196,23 +3955,7 @@ void bypass_caps_init(struct bpctl_dev *pbpctl_dev) } } -int bypass_off_init(struct bpctl_dev *pbpctl_dev) -{ - int ret = cmnd_on(pbpctl_dev); - if (ret < 0) - return ret; - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - return dis_bypass_cap(pbpctl_dev); - wdt_off(pbpctl_dev); - if (pbpctl_dev->bp_caps & BP_CAP) - bypass_off(pbpctl_dev); - if (pbpctl_dev->bp_caps & TAP_CAP) - tap_off(pbpctl_dev); - cmnd_off(pbpctl_dev); - return 0; -} - -void remove_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) +static void remove_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) { #ifdef BP_SELF_TEST struct bpctl_dev *pbpctl_dev_sl = NULL; @@ -4241,7 +3984,7 @@ void remove_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) } -int init_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) +static int init_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { init_timer(&pbpctl_dev->bp_timer); @@ -4288,7 +4031,7 @@ int bp_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } #endif -int set_bypass_wd_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) +static int set_bypass_wd_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { if (pbpctl_dev->reset_time != param) { @@ -4307,7 +4050,7 @@ int set_bypass_wd_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) return BP_NOT_CAP; } -int get_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) +static int get_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) return pbpctl_dev->reset_time; @@ -4378,7 +4121,7 @@ int is_bypass_fn(struct bpctl_dev *pbpctl_dev) return (((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) ? 1 : 0); } -int set_bypass_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) +static int set_bypass_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; @@ -4396,12 +4139,12 @@ int set_bypass_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) return ret; } -int get_bypass_fn(struct bpctl_dev *pbpctl_dev) +static int get_bypass_fn(struct bpctl_dev *pbpctl_dev) { return bypass_status(pbpctl_dev); } -int get_bypass_change_fn(struct bpctl_dev *pbpctl_dev) +static int get_bypass_change_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4409,7 +4152,7 @@ int get_bypass_change_fn(struct bpctl_dev *pbpctl_dev) return bypass_change_status(pbpctl_dev); } -int set_dis_bypass_fn(struct bpctl_dev *pbpctl_dev, int dis_param) +static int set_dis_bypass_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; if (!pbpctl_dev) @@ -4428,7 +4171,7 @@ int set_dis_bypass_fn(struct bpctl_dev *pbpctl_dev, int dis_param) return ret; } -int get_dis_bypass_fn(struct bpctl_dev *pbpctl_dev) +static int get_dis_bypass_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4436,7 +4179,7 @@ int get_dis_bypass_fn(struct bpctl_dev *pbpctl_dev) return dis_bypass_cap_status(pbpctl_dev); } -int set_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) +static int set_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; if (!pbpctl_dev) @@ -4455,7 +4198,7 @@ int set_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) return ret; } -int get_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev) +static int get_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4463,7 +4206,7 @@ int get_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev) return default_pwroff_status(pbpctl_dev); } -int set_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) +static int set_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; if (!pbpctl_dev) @@ -4482,7 +4225,7 @@ int set_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) return ret; } -int get_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev) +static int get_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4490,7 +4233,7 @@ int get_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev) return default_pwron_status(pbpctl_dev); } -int set_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int timeout) +static int set_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int timeout) { int ret = 0; if (!pbpctl_dev) @@ -4512,7 +4255,7 @@ int set_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int timeout) return ret; } -int get_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int *timeout) +static int get_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int *timeout) { if (!pbpctl_dev) return -1; @@ -4520,7 +4263,7 @@ int get_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int *timeout) return wdt_programmed(pbpctl_dev, timeout); } -int get_wd_expire_time_fn(struct bpctl_dev *pbpctl_dev, int *time_left) +static int get_wd_expire_time_fn(struct bpctl_dev *pbpctl_dev, int *time_left) { if (!pbpctl_dev) return -1; @@ -4528,7 +4271,7 @@ int get_wd_expire_time_fn(struct bpctl_dev *pbpctl_dev, int *time_left) return wdt_timer(pbpctl_dev, time_left); } -int reset_bypass_wd_timer_fn(struct bpctl_dev *pbpctl_dev) +static int reset_bypass_wd_timer_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4536,7 +4279,7 @@ int reset_bypass_wd_timer_fn(struct bpctl_dev *pbpctl_dev) return wdt_timer_reload(pbpctl_dev); } -int get_wd_set_caps_fn(struct bpctl_dev *pbpctl_dev) +static int get_wd_set_caps_fn(struct bpctl_dev *pbpctl_dev) { int bp_status = 0; @@ -4560,7 +4303,7 @@ int get_wd_set_caps_fn(struct bpctl_dev *pbpctl_dev) return bp_status; } -int set_std_nic_fn(struct bpctl_dev *pbpctl_dev, int nic_mode) +static int set_std_nic_fn(struct bpctl_dev *pbpctl_dev, int nic_mode) { int ret = 0; if (!pbpctl_dev) @@ -4580,7 +4323,7 @@ int set_std_nic_fn(struct bpctl_dev *pbpctl_dev, int nic_mode) return ret; } -int get_std_nic_fn(struct bpctl_dev *pbpctl_dev) +static int get_std_nic_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4588,7 +4331,7 @@ int get_std_nic_fn(struct bpctl_dev *pbpctl_dev) return std_nic_status(pbpctl_dev); } -int set_tap_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) +static int set_tap_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { if (!pbpctl_dev) return -1; @@ -4604,7 +4347,7 @@ int set_tap_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) return BP_NOT_CAP; } -int get_tap_fn(struct bpctl_dev *pbpctl_dev) +static int get_tap_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4612,7 +4355,7 @@ int get_tap_fn(struct bpctl_dev *pbpctl_dev) return tap_status(pbpctl_dev); } -int set_tap_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) +static int set_tap_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { int ret = 0; if (!pbpctl_dev) @@ -4630,7 +4373,7 @@ int set_tap_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) return ret; } -int get_tap_pwup_fn(struct bpctl_dev *pbpctl_dev) +static int get_tap_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4642,7 +4385,7 @@ int get_tap_pwup_fn(struct bpctl_dev *pbpctl_dev) return ((ret == 0) ? 1 : 0); } -int get_tap_change_fn(struct bpctl_dev *pbpctl_dev) +static int get_tap_change_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4650,7 +4393,7 @@ int get_tap_change_fn(struct bpctl_dev *pbpctl_dev) return tap_change_status(pbpctl_dev); } -int set_dis_tap_fn(struct bpctl_dev *pbpctl_dev, int dis_param) +static int set_dis_tap_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; if (!pbpctl_dev) @@ -4667,7 +4410,7 @@ int set_dis_tap_fn(struct bpctl_dev *pbpctl_dev, int dis_param) return BP_NOT_CAP; } -int get_dis_tap_fn(struct bpctl_dev *pbpctl_dev) +static int get_dis_tap_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4675,7 +4418,7 @@ int get_dis_tap_fn(struct bpctl_dev *pbpctl_dev) return dis_tap_cap_status(pbpctl_dev); } -int set_disc_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) +static int set_disc_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { if (!pbpctl_dev) return -1; @@ -4692,7 +4435,7 @@ int set_disc_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) return BP_NOT_CAP; } -int get_disc_fn(struct bpctl_dev *pbpctl_dev) +static int get_disc_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4703,7 +4446,7 @@ int get_disc_fn(struct bpctl_dev *pbpctl_dev) return ret; } -int set_disc_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) +static int set_disc_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { int ret = 0; if (!pbpctl_dev) @@ -4721,7 +4464,7 @@ int set_disc_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) return ret; } -int get_disc_pwup_fn(struct bpctl_dev *pbpctl_dev) +static int get_disc_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4731,7 +4474,7 @@ int get_disc_pwup_fn(struct bpctl_dev *pbpctl_dev) return (ret == 0 ? 1 : (ret < 0 ? BP_NOT_CAP : 0)); } -int get_disc_change_fn(struct bpctl_dev *pbpctl_dev) +static int get_disc_change_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4741,7 +4484,7 @@ int get_disc_change_fn(struct bpctl_dev *pbpctl_dev) return ret; } -int set_dis_disc_fn(struct bpctl_dev *pbpctl_dev, int dis_param) +static int set_dis_disc_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; if (!pbpctl_dev) @@ -4759,7 +4502,7 @@ int set_dis_disc_fn(struct bpctl_dev *pbpctl_dev, int dis_param) return BP_NOT_CAP; } -int get_dis_disc_fn(struct bpctl_dev *pbpctl_dev) +static int get_dis_disc_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4770,55 +4513,7 @@ int get_dis_disc_fn(struct bpctl_dev *pbpctl_dev) return ret; } -int set_disc_port_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) -{ - int ret = BP_NOT_CAP; - if (!pbpctl_dev) - return -1; - - if (!disc_mode) - ret = disc_port_off(pbpctl_dev); - else - ret = disc_port_on(pbpctl_dev); - - return ret; -} - -int get_disc_port_fn(struct bpctl_dev *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return disc_port_status(pbpctl_dev); -} - -int set_disc_port_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) -{ - int ret = BP_NOT_CAP; - if (!pbpctl_dev) - return -1; - - if (!disc_mode) - ret = normal_port_state_pwron(pbpctl_dev); - else - ret = disc_port_state_pwron(pbpctl_dev); - - return ret; -} - -int get_disc_port_pwup_fn(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - ret = default_pwron_disc_port_status(pbpctl_dev); - if (ret < 0) - return ret; - return ((ret == 0) ? 1 : 0); -} - -int get_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev) +static int get_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4826,7 +4521,7 @@ int get_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev) return wdt_exp_mode_status(pbpctl_dev); } -int set_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev, int param) +static int set_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev, int param) { if (!pbpctl_dev) return -1; @@ -4834,19 +4529,7 @@ int set_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev, int param) return wdt_exp_mode(pbpctl_dev, param); } -int reset_cont_fn(struct bpctl_dev *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - ret = cmnd_on(pbpctl_dev); - if (ret < 0) - return ret; - return reset_cont(pbpctl_dev); -} - -int set_tx_fn(struct bpctl_dev *pbpctl_dev, int tx_state) +static int set_tx_fn(struct bpctl_dev *pbpctl_dev, int tx_state) { struct bpctl_dev *pbpctl_dev_b = NULL; @@ -4867,7 +4550,7 @@ int set_tx_fn(struct bpctl_dev *pbpctl_dev, int tx_state) return set_tx(pbpctl_dev, tx_state); } -int set_bp_force_link_fn(int dev_num, int tx_state) +static int set_bp_force_link_fn(int dev_num, int tx_state) { static struct bpctl_dev *bpctl_dev_curr; @@ -4879,7 +4562,7 @@ int set_bp_force_link_fn(int dev_num, int tx_state) return set_bp_force_link(bpctl_dev_curr, tx_state); } -int set_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev, int param) +static int set_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev, int param) { if (!pbpctl_dev) return -1; @@ -4887,7 +4570,7 @@ int set_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev, int param) return set_bypass_wd_auto(pbpctl_dev, param); } -int get_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev) +static int get_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4914,7 +4597,7 @@ int get_bp_self_test_fn(struct bpctl_dev *pbpctl_dev) #endif -int get_bypass_caps_fn(struct bpctl_dev *pbpctl_dev) +static int get_bypass_caps_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4923,7 +4606,8 @@ int get_bypass_caps_fn(struct bpctl_dev *pbpctl_dev) } -int get_bypass_slave_fn(struct bpctl_dev *pbpctl_dev, struct bpctl_dev **pbpctl_dev_out) +static int get_bypass_slave_fn(struct bpctl_dev *pbpctl_dev, + struct bpctl_dev **pbpctl_dev_out) { int idx_dev = 0; if (!pbpctl_dev) @@ -4955,7 +4639,7 @@ int get_bypass_slave_fn(struct bpctl_dev *pbpctl_dev, struct bpctl_dev **pbpctl_ return 0; } -int is_bypass(struct bpctl_dev *pbpctl_dev) +static int is_bypass(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4966,7 +4650,7 @@ int is_bypass(struct bpctl_dev *pbpctl_dev) return 0; } -int get_tx_fn(struct bpctl_dev *pbpctl_dev) +static int get_tx_fn(struct bpctl_dev *pbpctl_dev) { struct bpctl_dev *pbpctl_dev_b = NULL; if (!pbpctl_dev) @@ -4986,7 +4670,7 @@ int get_tx_fn(struct bpctl_dev *pbpctl_dev) return tx_status(pbpctl_dev); } -int get_bp_force_link_fn(int dev_num) +static int get_bp_force_link_fn(int dev_num) { static struct bpctl_dev *bpctl_dev_curr; @@ -5049,7 +4733,7 @@ static void bp_tpl_timer_fn(unsigned long param) mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + BP_LINK_MON_DELAY * HZ); } -void remove_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) +static void remove_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) { struct bpctl_dev *pbpctl_dev_b = NULL; if (!pbpctl_dev) @@ -5067,7 +4751,7 @@ void remove_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) return; } -int init_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) +static int init_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -5080,7 +4764,7 @@ int init_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) return BP_NOT_CAP; } -int set_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) +static int set_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) { if (!pbpctl_dev) return -1; @@ -5098,17 +4782,7 @@ int set_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) return BP_NOT_CAP; } -int get_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - if (pbpctl_dev->bp_caps & TPL_CAP) - return pbpctl_dev->bp_tpl_flag; - - return BP_NOT_CAP; -} - -int set_tpl_fn(struct bpctl_dev *pbpctl_dev, int tpl_mode) +static int set_tpl_fn(struct bpctl_dev *pbpctl_dev, int tpl_mode) { struct bpctl_dev *pbpctl_dev_b = NULL; @@ -5138,7 +4812,7 @@ int set_tpl_fn(struct bpctl_dev *pbpctl_dev, int tpl_mode) return BP_NOT_CAP; } -int get_tpl_fn(struct bpctl_dev *pbpctl_dev) +static int get_tpl_fn(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if (!pbpctl_dev) @@ -5152,7 +4826,7 @@ int get_tpl_fn(struct bpctl_dev *pbpctl_dev) return ret; } -int set_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) +static int set_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { if (!pbpctl_dev) return -1; @@ -5172,7 +4846,7 @@ int set_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) return BP_NOT_CAP; } -int get_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev) +static int get_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -5185,7 +4859,7 @@ int get_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev) return ret; } -int set_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) +static int set_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { if (!pbpctl_dev) return -1; @@ -5205,7 +4879,7 @@ int set_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) return BP_NOT_CAP; } -int get_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev) +static int get_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -5220,7 +4894,7 @@ int get_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev) } -int get_bypass_info_fn(struct bpctl_dev *pbpctl_dev, char *dev_name, +static int get_bypass_info_fn(struct bpctl_dev *pbpctl_dev, char *dev_name, char *add_param) { if (!pbpctl_dev) @@ -7022,12 +6696,6 @@ int set_wd_exp_mode_sd(int ifindex, int param) } EXPORT_SYMBOL(set_wd_exp_mode_sd); -int reset_cont_sd(int ifindex) -{ - return reset_cont_fn(get_dev_idx_p(ifindex)); - -} - int set_tx_sd(int ifindex, int tx_state) { return set_tx_fn(get_dev_idx_p(ifindex), tx_state); From 417c070ad497126c7829625d74e034015aaa39ff Mon Sep 17 00:00:00 2001 From: Gary Rookard Date: Sat, 25 Jan 2014 04:03:14 -0500 Subject: [PATCH 0061/1375] Staging: rtl8821ae: fix up some spacing issues. I fixed up some operator spacing issues, and other minor spacing issues. Signed-off-by: Gary Alan Rookard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/base.c | 138 +++++++++++++++---------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8821ae/base.c b/drivers/staging/rtl8821ae/base.c index 18c936fbdf1e..30b3d3982703 100644 --- a/drivers/staging/rtl8821ae/base.c +++ b/drivers/staging/rtl8821ae/base.c @@ -64,73 +64,73 @@ * *********************************************************/ static struct ieee80211_channel rtl_channeltable_2g[] = { - {.center_freq = 2412,.hw_value = 1,}, - {.center_freq = 2417,.hw_value = 2,}, - {.center_freq = 2422,.hw_value = 3,}, - {.center_freq = 2427,.hw_value = 4,}, - {.center_freq = 2432,.hw_value = 5,}, - {.center_freq = 2437,.hw_value = 6,}, - {.center_freq = 2442,.hw_value = 7,}, - {.center_freq = 2447,.hw_value = 8,}, - {.center_freq = 2452,.hw_value = 9,}, - {.center_freq = 2457,.hw_value = 10,}, - {.center_freq = 2462,.hw_value = 11,}, - {.center_freq = 2467,.hw_value = 12,}, - {.center_freq = 2472,.hw_value = 13,}, - {.center_freq = 2484,.hw_value = 14,}, + {.center_freq = 2412, .hw_value = 1,}, + {.center_freq = 2417, .hw_value = 2,}, + {.center_freq = 2422, .hw_value = 3,}, + {.center_freq = 2427, .hw_value = 4,}, + {.center_freq = 2432, .hw_value = 5,}, + {.center_freq = 2437, .hw_value = 6,}, + {.center_freq = 2442, .hw_value = 7,}, + {.center_freq = 2447, .hw_value = 8,}, + {.center_freq = 2452, .hw_value = 9,}, + {.center_freq = 2457, .hw_value = 10,}, + {.center_freq = 2462, .hw_value = 11,}, + {.center_freq = 2467, .hw_value = 12,}, + {.center_freq = 2472, .hw_value = 13,}, + {.center_freq = 2484, .hw_value = 14,}, }; static struct ieee80211_channel rtl_channeltable_5g[] = { - {.center_freq = 5180,.hw_value = 36,}, - {.center_freq = 5200,.hw_value = 40,}, - {.center_freq = 5220,.hw_value = 44,}, - {.center_freq = 5240,.hw_value = 48,}, - {.center_freq = 5260,.hw_value = 52,}, - {.center_freq = 5280,.hw_value = 56,}, - {.center_freq = 5300,.hw_value = 60,}, - {.center_freq = 5320,.hw_value = 64,}, - {.center_freq = 5500,.hw_value = 100,}, - {.center_freq = 5520,.hw_value = 104,}, - {.center_freq = 5540,.hw_value = 108,}, - {.center_freq = 5560,.hw_value = 112,}, - {.center_freq = 5580,.hw_value = 116,}, - {.center_freq = 5600,.hw_value = 120,}, - {.center_freq = 5620,.hw_value = 124,}, - {.center_freq = 5640,.hw_value = 128,}, - {.center_freq = 5660,.hw_value = 132,}, - {.center_freq = 5680,.hw_value = 136,}, - {.center_freq = 5700,.hw_value = 140,}, - {.center_freq = 5745,.hw_value = 149,}, - {.center_freq = 5765,.hw_value = 153,}, - {.center_freq = 5785,.hw_value = 157,}, - {.center_freq = 5805,.hw_value = 161,}, - {.center_freq = 5825,.hw_value = 165,}, + {.center_freq = 5180, .hw_value = 36,}, + {.center_freq = 5200, .hw_value = 40,}, + {.center_freq = 5220, .hw_value = 44,}, + {.center_freq = 5240, .hw_value = 48,}, + {.center_freq = 5260, .hw_value = 52,}, + {.center_freq = 5280, .hw_value = 56,}, + {.center_freq = 5300, .hw_value = 60,}, + {.center_freq = 5320, .hw_value = 64,}, + {.center_freq = 5500, .hw_value = 100,}, + {.center_freq = 5520, .hw_value = 104,}, + {.center_freq = 5540, .hw_value = 108,}, + {.center_freq = 5560, .hw_value = 112,}, + {.center_freq = 5580, .hw_value = 116,}, + {.center_freq = 5600, .hw_value = 120,}, + {.center_freq = 5620, .hw_value = 124,}, + {.center_freq = 5640, .hw_value = 128,}, + {.center_freq = 5660, .hw_value = 132,}, + {.center_freq = 5680, .hw_value = 136,}, + {.center_freq = 5700, .hw_value = 140,}, + {.center_freq = 5745, .hw_value = 149,}, + {.center_freq = 5765, .hw_value = 153,}, + {.center_freq = 5785, .hw_value = 157,}, + {.center_freq = 5805, .hw_value = 161,}, + {.center_freq = 5825, .hw_value = 165,}, }; static struct ieee80211_rate rtl_ratetable_2g[] = { - {.bitrate = 10,.hw_value = 0x00,}, - {.bitrate = 20,.hw_value = 0x01,}, - {.bitrate = 55,.hw_value = 0x02,}, - {.bitrate = 110,.hw_value = 0x03,}, - {.bitrate = 60,.hw_value = 0x04,}, - {.bitrate = 90,.hw_value = 0x05,}, - {.bitrate = 120,.hw_value = 0x06,}, - {.bitrate = 180,.hw_value = 0x07,}, - {.bitrate = 240,.hw_value = 0x08,}, - {.bitrate = 360,.hw_value = 0x09,}, - {.bitrate = 480,.hw_value = 0x0a,}, - {.bitrate = 540,.hw_value = 0x0b,}, + {.bitrate = 10, .hw_value = 0x00,}, + {.bitrate = 20, .hw_value = 0x01,}, + {.bitrate = 55, .hw_value = 0x02,}, + {.bitrate = 110, .hw_value = 0x03,}, + {.bitrate = 60, .hw_value = 0x04,}, + {.bitrate = 90, .hw_value = 0x05,}, + {.bitrate = 120, .hw_value = 0x06,}, + {.bitrate = 180, .hw_value = 0x07,}, + {.bitrate = 240, .hw_value = 0x08,}, + {.bitrate = 360, .hw_value = 0x09,}, + {.bitrate = 480, .hw_value = 0x0a,}, + {.bitrate = 540, .hw_value = 0x0b,}, }; static struct ieee80211_rate rtl_ratetable_5g[] = { - {.bitrate = 60,.hw_value = 0x04,}, - {.bitrate = 90,.hw_value = 0x05,}, - {.bitrate = 120,.hw_value = 0x06,}, - {.bitrate = 180,.hw_value = 0x07,}, - {.bitrate = 240,.hw_value = 0x08,}, - {.bitrate = 360,.hw_value = 0x09,}, - {.bitrate = 480,.hw_value = 0x0a,}, - {.bitrate = 540,.hw_value = 0x0b,}, + {.bitrate = 60, .hw_value = 0x04,}, + {.bitrate = 90, .hw_value = 0x05,}, + {.bitrate = 120, .hw_value = 0x06,}, + {.bitrate = 180, .hw_value = 0x07,}, + {.bitrate = 240, .hw_value = 0x08,}, + {.bitrate = 360, .hw_value = 0x09,}, + {.bitrate = 480, .hw_value = 0x0a,}, + {.bitrate = 540, .hw_value = 0x0b,}, }; static const struct ieee80211_supported_band rtl_band_2ghz = { @@ -320,7 +320,7 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) /* <5> set hw caps */ hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_RX_INCLUDES_FCS | -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) IEEE80211_HW_BEACON_FILTER | #endif IEEE80211_HW_AMPDU_AGGREGATION | @@ -336,7 +336,7 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) /* IEEE80211_HW_SUPPORTS_DYNAMIC_PS | */ 0; /**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_STATION) | @@ -354,11 +354,11 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) /**/ #endif /**/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,39)) +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)) hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; #endif @@ -402,7 +402,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw) /* <2> work queue */ rtlpriv->works.hw = hw; /**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) /**/ rtlpriv->works.rtl_wq = alloc_workqueue(rtlpriv->cfg->name, 0, 0); /**/ @@ -730,7 +730,7 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw, struct rtl_phy *rtlphy = &(rtlpriv->phy); u8 hw_rate; - if ((get_rf_type(rtlphy) == RF_2T2R) && (sta->ht_cap.mcs.rx_mask[1]!=0)) + if ((get_rf_type(rtlphy) == RF_2T2R) && (sta->ht_cap.mcs.rx_mask[1] != 0)) hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15]; else hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS7]; @@ -781,7 +781,7 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, if (sta && (sta->ht_cap.ht_supported)) { tcb_desc->hw_rate = _rtl_get_highest_n_rate(hw, sta); } else { - if(rtlmac->mode == WIRELESS_MODE_B) { + if (rtlmac->mode == WIRELESS_MODE_B) { tcb_desc->hw_rate = rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M]; } else { @@ -897,7 +897,7 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) hdr->addr3, tid); if (skb_delba) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) rx_status.freq = hw->conf.chandef.chan->center_freq; rx_status.band = hw->conf.chandef.chan->band; #else @@ -1184,7 +1184,7 @@ void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb) if (ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid)) return; - rtlpriv->link_info.bcn_rx_inperiod ++; + rtlpriv->link_info.bcn_rx_inperiod++; } void rtl_watchdog_wq_callback(void *data) @@ -1478,13 +1478,13 @@ int rtl_send_smps_action(struct ieee80211_hw *hw, /* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); */ info->control.rates[0].idx = 0; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) info->band = hw->conf.chandef.chan->band; #else info->band = hw->conf.channel->band; #endif /**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) info->control.sta = sta; rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); #else From 79285edd366089b5af76e9249d495e097aaa07a6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 28 Jan 2014 17:00:52 +0300 Subject: [PATCH 0062/1375] staging: rtl8821ae: a couple macro expansion bugs These macros need parentheses, otherwise it causes a macro expansion bug when they are used like this: ch->flags &= ~IEEE80211_CHAN_NO_IBSS; This was found using Smatch: drivers/staging/rtl8821ae/regd.c:200 _rtl_reg_apply_beaconing_flags() warn: the 'IEEE80211_CHAN_NO_IBSS' macro might need parens Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/regd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8821ae/regd.h b/drivers/staging/rtl8821ae/regd.h index abc60ab8165c..dceb3f18200b 100644 --- a/drivers/staging/rtl8821ae/regd.h +++ b/drivers/staging/rtl8821ae/regd.h @@ -30,8 +30,8 @@ #ifndef __RTL_REGD_H__ #define __RTL_REGD_H__ -#define IEEE80211_CHAN_NO_IBSS 1<<2 -#define IEEE80211_CHAN_PASSIVE_SCAN 1<<1 +#define IEEE80211_CHAN_NO_IBSS (1 << 2) +#define IEEE80211_CHAN_PASSIVE_SCAN (1 << 1) #define WIPHY_FLAG_CUSTOM_REGULATORY BIT(0) #define WIPHY_FLAG_STRICT_REGULATORY BIT(1) #define WIPHY_FLAG_DISABLE_BEACON_HINTS BIT(2) From 114efd70707897d02790617012c5da1847911943 Mon Sep 17 00:00:00 2001 From: Gokulnath A Date: Fri, 7 Feb 2014 00:45:22 +0530 Subject: [PATCH 0063/1375] staging:rtl8821ae: trailing whitespace cleanup in pci.c Fixed all the trailing whitespace errors found by checkpatch.pl script Signed-off-by: Gokulnath A Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/pci.c | 250 ++++++++++++++++---------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/drivers/staging/rtl8821ae/pci.c b/drivers/staging/rtl8821ae/pci.c index cfa651edd238..618a3cb4a0c0 100644 --- a/drivers/staging/rtl8821ae/pci.c +++ b/drivers/staging/rtl8821ae/pci.c @@ -388,13 +388,13 @@ static u8 _rtl_pci_get_pciehdr_offset(struct ieee80211_hw *hw) * capability that we are looking for, follow the link to * the next capability and continue looping. */ - rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS , - pcicfg_addr_port + + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS , + pcicfg_addr_port + (num4bytes << 2)); rtl_pci_raw_read_port_ushort(PCI_CONF_DATA, (u16*)&capability_hdr); /* Found the PCI express capability. */ - if (capability_hdr.capability_id == + if (capability_hdr.capability_id == PCI_CAPABILITY_ID_PCI_EXPRESS) break; else @@ -418,7 +418,7 @@ bool rtl_pci_check_buddy_priv(struct ieee80211_hw *hw, list_for_each_entry(temp_priv, &rtlpriv->glb_var->glb_priv_list, list) { if (temp_priv) { - temp_pcipriv = + temp_pcipriv = (struct rtl_pci_priv *)temp_priv->priv; RT_TRACE(COMP_INIT, DBG_LOUD, (("pcipriv->ndis_adapter.funcnumber %x \n"), @@ -526,8 +526,8 @@ static void _rtl_pci_io_handler_init(struct device *dev, } static bool _rtl_pci_update_earlymode_info(struct ieee80211_hw *hw, - struct sk_buff *skb, - struct rtl_tcb_desc *tcb_desc, + struct sk_buff *skb, + struct rtl_tcb_desc *tcb_desc, u8 tid) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -535,7 +535,7 @@ static bool _rtl_pci_update_earlymode_info(struct ieee80211_hw *hw, struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u8 additionlen = FCS_LEN; struct sk_buff *next_skb; - + /* here open is 4, wep/tkip is 8, aes is 12*/ if (info->control.hw_key) additionlen += info->control.hw_key->icv_len; @@ -544,7 +544,7 @@ static bool _rtl_pci_update_earlymode_info(struct ieee80211_hw *hw, tcb_desc->empkt_num = 0; spin_lock_bh(&rtlpriv->locks.waitq_lock); skb_queue_walk(&rtlpriv->mac80211.skb_waitq[tid], next_skb) { - struct ieee80211_tx_info *next_info = + struct ieee80211_tx_info *next_info = IEEE80211_SKB_CB(next_skb); if (next_info->flags & IEEE80211_TX_CTL_AMPDU) { tcb_desc->empkt_len[tcb_desc->empkt_num] = @@ -554,7 +554,7 @@ static bool _rtl_pci_update_earlymode_info(struct ieee80211_hw *hw, break; } - if (skb_queue_is_last(&rtlpriv->mac80211.skb_waitq[tid], + if (skb_queue_is_last(&rtlpriv->mac80211.skb_waitq[tid], next_skb)) break; @@ -575,26 +575,26 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw) struct sk_buff *skb = NULL; struct ieee80211_tx_info *info = NULL; int tid; /* should be int */ - + if (!rtlpriv->rtlhal.b_earlymode_enable) - return; + return; if (rtlpriv->dm.supp_phymode_switch && (rtlpriv->easy_concurrent_ctl.bswitch_in_process || - (rtlpriv->buddy_priv && + (rtlpriv->buddy_priv && rtlpriv->buddy_priv->easy_concurrent_ctl.bswitch_in_process))) return; /* we juse use em for BE/BK/VI/VO */ for (tid = 7; tid >= 0; tid--) { u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(hw, tid)]; struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; - while (!mac->act_scanning && + while (!mac->act_scanning && rtlpriv->psc.rfpwr_state == ERFON) { struct rtl_tcb_desc tcb_desc; - memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); spin_lock_bh(&rtlpriv->locks.waitq_lock); if (!skb_queue_empty(&mac->skb_waitq[tid]) && - (ring->entries - skb_queue_len(&ring->queue) > + (ring->entries - skb_queue_len(&ring->queue) > rtlhal->max_earlymode_num)) { skb = skb_dequeue(&mac->skb_waitq[tid]); } else { @@ -607,7 +607,7 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw) * multicast/broadcast/no_qos data */ info = IEEE80211_SKB_CB(skb); if (info->flags & IEEE80211_TX_CTL_AMPDU) - _rtl_pci_update_earlymode_info(hw, skb, + _rtl_pci_update_earlymode_info(hw, skb, &tcb_desc, tid); /**/ @@ -635,7 +635,7 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) u8 tid; u8 *entry; - + if (rtlpriv->use_new_trx_flow) entry = (u8 *)(&ring->buffer_desc[ring->idx]); else @@ -643,11 +643,11 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) if (!rtlpriv->cfg->ops->is_tx_desc_closed(hw, prio, ring->idx)) return; - + ring->idx = (ring->idx + 1) % ring->entries; - + skb = __skb_dequeue(&ring->queue); - + pci_unmap_single(rtlpci->pdev, le32_to_cpu(rtlpriv->cfg->ops-> get_desc((u8 *) entry, true, @@ -740,7 +740,7 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw, u8 tmp_one = 1; struct sk_buff *skb; - skb = dev_alloc_skb(rtlpci->rxbuffersize); + skb = dev_alloc_skb(rtlpci->rxbuffersize); if (!skb) return 0; rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb; @@ -754,21 +754,21 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw, if (pci_dma_mapping_error(rtlpci->pdev, bufferaddress)) return 0; if (rtlpriv->use_new_trx_flow) { - rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, + rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, HW_DESC_RX_PREPARE, (u8 *) & bufferaddress); - } else { - rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, + } else { + rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, HW_DESC_RXBUFF_ADDR, (u8 *) & bufferaddress); - rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, + rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, HW_DESC_RXPKT_LEN, (u8 *) & rtlpci->rxbuffersize); - rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, + rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, HW_DESC_RXOWN, (u8 *) & tmp_one); } - + return 1; } @@ -792,7 +792,7 @@ static void _rtl_pci_rx_to_mac80211(struct ieee80211_hw *hw, } else { struct sk_buff *uskb = NULL; u8 *pdata; - + uskb = dev_alloc_skb(skb->len + 128); if (likely(uskb)) { memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, @@ -804,7 +804,7 @@ static void _rtl_pci_rx_to_mac80211(struct ieee80211_hw *hw, ieee80211_rx_irqsafe(hw, uskb); } else { ieee80211_rx_irqsafe(hw, skb); - } + } } } @@ -814,11 +814,11 @@ static void _rtl_pci_hs_interrupt(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[MAC_HSISR], - rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[MAC_HSISR]) | + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[MAC_HSISR], + rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[MAC_HSISR]) | rtlpci->sys_irq_mask); - + } static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) { @@ -839,7 +839,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) .noise = -98, .rate = 0, }; - + /*RX NORMAL PKT */ while (count--) { struct ieee80211_hdr *hdr; @@ -852,65 +852,65 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) /*rx pkt */ struct sk_buff *skb = rtlpci->rx_ring[rxring_idx].rx_buf[ rtlpci->rx_ring[rxring_idx].idx]; - + if (rtlpriv->use_new_trx_flow) { - rx_remained_cnt = + rx_remained_cnt = rtlpriv->cfg->ops->rx_desc_buff_remained_cnt(hw, hw_queue); - if (rx_remained_cnt < 1) + if (rx_remained_cnt < 1) return; - + } else { /* rx descriptor */ pdesc = &rtlpci->rx_ring[rxring_idx].desc[ rtlpci->rx_ring[rxring_idx].idx]; - + own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, - false, + false, HW_DESC_OWN); if (own) /* wait data to be filled by hardware */ return; } - + /* Get here means: data is filled already*/ /* AAAAAAttention !!! * We can NOT access 'skb' before 'pci_unmap_single' */ pci_unmap_single(rtlpci->pdev, *((dma_addr_t *) skb->cb), rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE); - + if (rtlpriv->use_new_trx_flow) { buffer_desc = &rtlpci->rx_ring[rxring_idx].buffer_desc[ rtlpci->rx_ring[rxring_idx].idx]; /*means rx wifi info*/ pdesc = (struct rtl_rx_desc *)skb->data; } - + rtlpriv->cfg->ops->query_rx_desc(hw, &status, &rx_status, (u8 *) pdesc, skb); - + if (rtlpriv->use_new_trx_flow) - rtlpriv->cfg->ops->rx_check_dma_ok(hw, - (u8 *)buffer_desc, + rtlpriv->cfg->ops->rx_check_dma_ok(hw, + (u8 *)buffer_desc, hw_queue); - - len = rtlpriv->cfg->ops->get_desc((u8 *)pdesc, false, + + len = rtlpriv->cfg->ops->get_desc((u8 *)pdesc, false, HW_DESC_RXPKT_LEN); - + if (skb->end - skb->tail > len) { skb_put(skb, len); - if (rtlpriv->use_new_trx_flow) - skb_reserve(skb, status.rx_drvinfo_size + + if (rtlpriv->use_new_trx_flow) + skb_reserve(skb, status.rx_drvinfo_size + status.rx_bufshift + 24); else - skb_reserve(skb, status.rx_drvinfo_size + + skb_reserve(skb, status.rx_drvinfo_size + status.rx_bufshift); } else { - printk("skb->end - skb->tail = %d, len is %d\n", + printk("skb->end - skb->tail = %d, len is %d\n", skb->end - skb->tail, len); break; } - + rtlpriv->cfg->ops->rx_command_packet_handler(hw, status, skb); /* @@ -922,9 +922,9 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) hdr = rtl_get_hdr(skb); fc = rtl_get_fc(skb); - + if (!status.b_crc && !status.b_hwerror) { - memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, + memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); if (is_broadcast_ether_addr(hdr->addr1)) { @@ -947,13 +947,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) /* static bcn for roaming */ rtl_beacon_statistic(hw, skb); - rtl_p2p_info(hw, (void*)skb->data, skb->len); + rtl_p2p_info(hw, (void*)skb->data, skb->len); /* for sw lps */ rtl_swlps_beacon(hw, (void*)skb->data, skb->len); rtl_recognize_peer(hw, (void*)skb->data, skb->len); if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)&& - (ieee80211_is_beacon(fc) || + (ieee80211_is_beacon(fc) || ieee80211_is_probe_resp(fc))) { dev_kfree_skb_any(skb); } else { @@ -964,13 +964,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) } if (rtlpriv->use_new_trx_flow) { rtlpci->rx_ring[hw_queue].next_rx_rp += 1; - rtlpci->rx_ring[hw_queue].next_rx_rp %= + rtlpci->rx_ring[hw_queue].next_rx_rp %= RTL_PCI_MAX_RX_COUNT; rx_remained_cnt--; if (1/*rx_remained_cnt == 0*/) { - rtl_write_word(rtlpriv, 0x3B4, + rtl_write_word(rtlpriv, 0x3B4, rtlpci->rx_ring[hw_queue].next_rx_rp); } } @@ -981,22 +981,22 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) } if (rtlpriv->use_new_trx_flow) { - _rtl_pci_init_one_rxdesc(hw, (u8 *)buffer_desc, + _rtl_pci_init_one_rxdesc(hw, (u8 *)buffer_desc, rxring_idx, - rtlpci->rx_ring[rxring_idx].idx); + rtlpci->rx_ring[rxring_idx].idx); } else { _rtl_pci_init_one_rxdesc(hw, (u8 *)pdesc, rxring_idx, - rtlpci->rx_ring[rxring_idx].idx); + rtlpci->rx_ring[rxring_idx].idx); - if (rtlpci->rx_ring[rxring_idx].idx == + if (rtlpci->rx_ring[rxring_idx].idx == rtlpci->rxringcount - 1) - rtlpriv->cfg->ops->set_desc(hw, (u8 *) pdesc, - false, + rtlpriv->cfg->ops->set_desc(hw, (u8 *) pdesc, + false, HW_DESC_RXERO, (u8 *) & tmp_one); } - rtlpci->rx_ring[rxring_idx].idx = - (rtlpci->rx_ring[rxring_idx].idx + 1) % + rtlpci->rx_ring[rxring_idx].idx = + (rtlpci->rx_ring[rxring_idx].idx + 1) % rtlpci->rxringcount; } } @@ -1011,7 +1011,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) u32 inta = 0; u32 intb = 0; - + if (rtlpci->irq_enabled == 0) return IRQ_HANDLED; @@ -1020,7 +1020,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMR], 0x0); - + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMRE], 0x0); @@ -1127,7 +1127,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) /*<4> fw related*/ if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723AE) { if (inta & rtlpriv->cfg->maps[RTL_IMR_C2HCMD]) { - RT_TRACE(COMP_INTR, DBG_TRACE, + RT_TRACE(COMP_INTR, DBG_TRACE, ("firmware interrupt!\n")); queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.fwevt_wq, 0); @@ -1142,12 +1142,12 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) if (rtlhal->hw_type == HARDWARE_TYPE_RTL8188EE || rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_HSISR_IND])) { - RT_TRACE(COMP_INTR, DBG_TRACE, + RT_TRACE(COMP_INTR, DBG_TRACE, ("hsisr interrupt!\n")); _rtl_pci_hs_interrupt(hw); } } - + if(rtlpriv->rtlhal.b_earlymode_enable) tasklet_schedule(&rtlpriv->works.irq_tasklet); @@ -1157,7 +1157,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMRE], rtlpci->irq_mask[1]); spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); - + return IRQ_HANDLED; done: @@ -1200,16 +1200,16 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw) pdesc = &ring->desc[0]; if (rtlpriv->use_new_trx_flow) pbuffer_desc = &ring->buffer_desc[0]; - + /**/ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, - (u8 *)pbuffer_desc, info, pskb, + rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, + (u8 *)pbuffer_desc, info, pskb, BEACON_QUEUE, &tcb_desc); #else /**/ rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, - (u8 *)pbuffer_desc, info, NULL, pskb, + (u8 *)pbuffer_desc, info, NULL, pskb, BEACON_QUEUE, &tcb_desc); /**/ #endif @@ -1235,7 +1235,7 @@ static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) desc_num = TX_DESC_NUM_92E; else desc_num = RT_TXDESC_NUM; - + for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) { rtlpci->txringcount[i] = desc_num; } @@ -1309,12 +1309,12 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, /* alloc tx buffer desc for new trx flow*/ if (rtlpriv->use_new_trx_flow) { buffer_desc = pci_alloc_consistent(rtlpci->pdev, - sizeof(*buffer_desc) * entries, + sizeof(*buffer_desc) * entries, &buffer_desc_dma); if (!buffer_desc || (unsigned long)buffer_desc & 0xFF) { RT_TRACE(COMP_ERR, DBG_EMERG, - ("Cannot allocate TX ring (prio = %d)\n", + ("Cannot allocate TX ring (prio = %d)\n", prio)); return -ENOMEM; } @@ -1322,13 +1322,13 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, memset(buffer_desc, 0, sizeof(*buffer_desc) * entries); rtlpci->tx_ring[prio].buffer_desc = buffer_desc; rtlpci->tx_ring[prio].buffer_desc_dma = buffer_desc_dma; - + rtlpci->tx_ring[prio].cur_tx_rp = 0; rtlpci->tx_ring[prio].cur_tx_wp = 0; rtlpci->tx_ring[prio].avl_desc = entries; } - + /* alloc dma for this ring */ desc = pci_alloc_consistent(rtlpci->pdev, sizeof(*desc) * entries, &desc_dma); @@ -1342,7 +1342,7 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, memset(desc, 0, sizeof(*desc) * entries); rtlpci->tx_ring[prio].desc = desc; rtlpci->tx_ring[prio].dma = desc_dma; - + rtlpci->tx_ring[prio].idx = 0; rtlpci->tx_ring[prio].entries = entries; skb_queue_head_init(&rtlpci->tx_ring[prio].queue); @@ -1357,7 +1357,7 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, sizeof(*desc)); rtlpriv->cfg->ops->set_desc(hw, (u8 *) & (desc[i]), - true, + true, HW_DESC_TX_NEXTDESC_ADDR, (u8 *) & nextdescaddress); } @@ -1371,15 +1371,15 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx) struct rtl_priv *rtlpriv = rtl_priv(hw); int i; - + if (rtlpriv->use_new_trx_flow) { struct rtl_rx_buffer_desc *entry = NULL; /* alloc dma for this ring */ - rtlpci->rx_ring[rxring_idx].buffer_desc = + rtlpci->rx_ring[rxring_idx].buffer_desc = pci_alloc_consistent(rtlpci->pdev, sizeof(*rtlpci->rx_ring[rxring_idx]. - buffer_desc) * - rtlpci->rxringcount, + buffer_desc) * + rtlpci->rxringcount, &rtlpci->rx_ring[rxring_idx].dma); if (!rtlpci->rx_ring[rxring_idx].buffer_desc || (unsigned long)rtlpci->rx_ring[rxring_idx].buffer_desc & 0xFF) { @@ -1393,9 +1393,9 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx) /* init every desc in this ring */ rtlpci->rx_ring[rxring_idx].idx = 0; - for (i = 0; i < rtlpci->rxringcount; i++) { + for (i = 0; i < rtlpci->rxringcount; i++) { entry = &rtlpci->rx_ring[rxring_idx].buffer_desc[i]; - if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry, + if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry, rxring_idx, i)) return -ENOMEM; } @@ -1403,14 +1403,14 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx) struct rtl_rx_desc *entry = NULL; u8 tmp_one = 1; /* alloc dma for this ring */ - rtlpci->rx_ring[rxring_idx].desc = + rtlpci->rx_ring[rxring_idx].desc = pci_alloc_consistent(rtlpci->pdev, sizeof(*rtlpci->rx_ring[rxring_idx]. - desc) * rtlpci->rxringcount, + desc) * rtlpci->rxringcount, &rtlpci->rx_ring[rxring_idx].dma); if (!rtlpci->rx_ring[rxring_idx].desc || (unsigned long)rtlpci->rx_ring[rxring_idx].desc & 0xFF) { - RT_TRACE(COMP_ERR, DBG_EMERG, + RT_TRACE(COMP_ERR, DBG_EMERG, ("Cannot allocate RX ring\n")); return -ENOMEM; } @@ -1421,9 +1421,9 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx) /* init every desc in this ring */ rtlpci->rx_ring[rxring_idx].idx = 0; - for (i = 0; i < rtlpci->rxringcount; i++) { + for (i = 0; i < rtlpci->rxringcount; i++) { entry = &rtlpci->rx_ring[rxring_idx].desc[i]; - if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry, + if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry, rxring_idx, i)) return -ENOMEM; } @@ -1467,7 +1467,7 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw, sizeof(*ring->buffer_desc) * ring->entries, ring->buffer_desc, ring->buffer_desc_dma); ring->buffer_desc = NULL; - } + } } static void _rtl_pci_free_rx_ring(struct ieee80211_hw *hw, int rxring_idx) @@ -1532,7 +1532,7 @@ err_free_rings: _rtl_pci_free_rx_ring(hw, rxring_idx); for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) - if (rtlpci->tx_ring[i].desc || + if (rtlpci->tx_ring[i].desc || rtlpci->tx_ring[i].buffer_desc) _rtl_pci_free_tx_ring(hw, i); @@ -1567,16 +1567,16 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw) /* force the rx_ring[RX_MPDU_QUEUE/ * RX_CMD_QUEUE].idx to the first one */ /*new trx flow, do nothing*/ - if ((rtlpriv->use_new_trx_flow == false) && + if ((rtlpriv->use_new_trx_flow == false) && rtlpci->rx_ring[rxring_idx].desc) { struct rtl_rx_desc *entry = NULL; for (i = 0; i < rtlpci->rxringcount; i++) { - entry = &rtlpci->rx_ring[rxring_idx].desc[i]; - rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, + entry = &rtlpci->rx_ring[rxring_idx].desc[i]; + rtlpriv->cfg->ops->set_desc(hw, (u8 *) entry, false, - HW_DESC_RXOWN, - (u8 *) & tmp_one); + HW_DESC_RXOWN, + (u8 *) & tmp_one); } } rtlpci->rx_ring[rxring_idx].idx = 0; } @@ -1585,13 +1585,13 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw) * and force the tx idx to the first one */ spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) { - if (rtlpci->tx_ring[i].desc || + if (rtlpci->tx_ring[i].desc || rtlpci->tx_ring[i].buffer_desc) { struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[i]; while (skb_queue_len(&ring->queue)) { u8 *entry; - struct sk_buff *skb = + struct sk_buff *skb = __skb_dequeue(&ring->queue); if (rtlpriv->use_new_trx_flow) entry = (u8 *)(&ring->buffer_desc @@ -1618,7 +1618,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw) /**/ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) -static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, +static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, struct sk_buff *skb) #else /**/ @@ -1741,10 +1741,10 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, } pdesc = &ring->desc[idx]; - + if (rtlpriv->use_new_trx_flow) { ptx_bd_desc = &ring->buffer_desc[idx]; - } else { + } else { own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, true, HW_DESC_OWN); @@ -1755,17 +1755,17 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, hw_queue, ring->idx, idx, skb_queue_len(&ring->queue))); - spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); return skb->len; } } - + if (ieee80211_is_data_qos(fc)) { tid = rtl_get_tid(skb); if (sta) { sta_entry = (struct rtl_sta_info *)sta->drv_priv; - seq_number = (le16_to_cpu(hdr->seq_ctrl) & + seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; seq_number += 1; @@ -1779,13 +1779,13 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, /**/ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, - (u8 *)ptx_bd_desc, info, skb, + rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, + (u8 *)ptx_bd_desc, info, skb, hw_queue, ptcb_desc); #else /**/ - rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, - (u8 *)ptx_bd_desc, info, sta, skb, + rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, + (u8 *)ptx_bd_desc, info, sta, skb, hw_queue, ptcb_desc); /**/ #endif @@ -1832,10 +1832,10 @@ static void rtl_pci_flush(struct ieee80211_hw *hw, bool drop) u16 i = 0; int queue_id; struct rtl8192_tx_ring *ring; - + if (mac->skip_scan) return; - + for (queue_id = RTL_PCI_MAX_TX_QUEUE_COUNT - 1; queue_id >= 0;) { u32 queue_len; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) @@ -2081,13 +2081,13 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, rtlhal->interfaceindex = 0; } } - + /* 92ee use new trx flow */ if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) rtlpriv->use_new_trx_flow = true; else rtlpriv->use_new_trx_flow = false; - + /*find bus info */ pcipriv->ndis_adapter.busnumber = pdev->bus->number; pcipriv->ndis_adapter.devnumber = PCI_SLOT(pdev->devfn); @@ -2095,7 +2095,7 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, /*find bridge info */ pcipriv->ndis_adapter.pcibridge_vendor = PCI_BRIDGE_VENDOR_UNKNOWN; - /* some ARM have no bridge_pdev and will crash here + /* some ARM have no bridge_pdev and will crash here * so we should check if bridge_pdev is NULL */ if (bridge_pdev) { pcipriv->ndis_adapter.pcibridge_vendorid = bridge_pdev->vendor; @@ -2187,7 +2187,7 @@ static int rtl_pci_intr_mode_msi(struct ieee80211_hw *hw) } rtlpci->using_msi = true; - + RT_TRACE(COMP_INIT|COMP_INTR, DBG_DMESG, ("MSI Interrupt Mode!\n")); return 0; } @@ -2198,7 +2198,7 @@ static int rtl_pci_intr_mode_legacy(struct ieee80211_hw *hw) struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); int ret; - + ret = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt, IRQF_SHARED, KBUILD_MODNAME, hw); if (ret < 0) { @@ -2206,7 +2206,7 @@ static int rtl_pci_intr_mode_legacy(struct ieee80211_hw *hw) } rtlpci->using_msi = false; - RT_TRACE(COMP_INIT|COMP_INTR, DBG_DMESG, + RT_TRACE(COMP_INIT|COMP_INTR, DBG_DMESG, ("Pin-based Interrupt Mode!\n")); return 0; } @@ -2377,7 +2377,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, } else { rtlpriv->mac80211.mac80211_registered = 1; } - /* the wiphy must have been registed to + /* the wiphy must have been registed to * cfg80211 prior to regulatory_hint */ if (regulatory_hint(hw->wiphy, rtlpriv->regd.alpha2)) { RT_TRACE(COMP_ERR, DBG_WARNING, ("regulatory_hint fail\n")); @@ -2450,7 +2450,7 @@ void rtl_pci_disconnect(struct pci_dev *pdev) /* add for prov */ rtl_proc_remove_one(hw); - + /*ieee80211_unregister_hw will call ops_stop */ if (rtlmac->mac80211_registered == 1) { @@ -2529,7 +2529,7 @@ int rtl_pci_resume(struct device *dev) rtlpriv->cfg->ops->hw_resume(hw); rtl_init_rfkill(hw); - + return 0; } //EXPORT_SYMBOL(rtl_pci_resume); From ab0c069ab59aba0dd21b3e52e81a88f2c21e4448 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 27 Jan 2014 12:17:05 +0530 Subject: [PATCH 0064/1375] staging: ion: Use PTR_ERR_OR_ZERO PTR_RET is deprecated. Use PTR_ERR_OR_ZERO instead. While at it also use PTR_ERR_OR_ZERO in ion.c to simplify the code. Signed-off-by: Sachin Kamat Cc: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 5 ++--- drivers/staging/android/ion/ion_heap.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 574066ff73f8..b3395924f03e 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -1017,9 +1018,7 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, size_t start, mutex_lock(&buffer->lock); vaddr = ion_buffer_kmap_get(buffer); mutex_unlock(&buffer->lock); - if (IS_ERR(vaddr)) - return PTR_ERR(vaddr); - return 0; + return PTR_ERR_OR_ZERO(vaddr); } static void ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf, size_t start, diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index 296c74f98dc0..03cc43222b50 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c @@ -247,7 +247,7 @@ int ion_heap_init_deferred_free(struct ion_heap *heap) if (IS_ERR(heap->task)) { pr_err("%s: creating thread for deferred free failed\n", __func__); - return PTR_RET(heap->task); + return PTR_ERR_OR_ZERO(heap->task); } return 0; } From 5556734959ab7d600552eca8eabe9a8321c83586 Mon Sep 17 00:00:00 2001 From: Gary Servin Date: Sun, 26 Jan 2014 13:00:18 -0300 Subject: [PATCH 0065/1375] staging: olpc_dcon: Trivial: Remove space before indentation. This coding style error was detected using the checkpatch.pl script Signed-off-by: Gary Servin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index e2663b189c66..aec98958f795 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h @@ -37,7 +37,7 @@ /* Load Delay Locked Loop (DLL) settings for clock delay */ #define MEM_DLL_CLOCK_DELAY (1<<0) /* Memory controller power down function */ -#define MEM_POWER_DOWN (1<<8) +#define MEM_POWER_DOWN (1<<8) /* Memory controller software reset */ #define MEM_SOFT_RESET (1<<0) From 0d5de1777684bdb8d28aaa99891be9c7b55b83e8 Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Mon, 3 Feb 2014 14:40:25 -0800 Subject: [PATCH 0066/1375] staging: rtl8192u: remove unused files I was doing some code audits looking at scattergather uses, and noticed that update() in drivers/staging/rtl8192u/ieee80211/digest.c uses sg.page which doesn't exist any longer, so this can't possibly compile. Turns out that digest.c is actually unused. It doesn't get referenced in a Makefile or get compiled and doesn't get used as far as I can see. I then widened the search to all the files in the directory. There are a *bunch* that look unused. I removed all of them, then added them back one at a time until the driver compiled again. Signed-off-by: Dave Hansen Cc: jerry-chuang@realtek.com Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/EndianFree.h | 194 -------- drivers/staging/rtl8192u/ieee80211/aes.c | 468 ------------------ drivers/staging/rtl8192u/ieee80211/arc4.c | 103 ---- drivers/staging/rtl8192u/ieee80211/autoload.c | 40 -- drivers/staging/rtl8192u/ieee80211/cipher.c | 298 ----------- drivers/staging/rtl8192u/ieee80211/compress.c | 64 --- .../rtl8192u/ieee80211/crypto_compat.h | 58 --- drivers/staging/rtl8192u/ieee80211/digest.c | 108 ---- drivers/staging/rtl8192u/ieee80211/internal.h | 81 --- .../staging/rtl8192u/ieee80211/michael_mic.c | 194 -------- drivers/staging/rtl8192u/ieee80211/proc.c | 112 ----- .../staging/rtl8192u/ieee80211/rtl_crypto.h | 398 --------------- .../staging/rtl8192u/ieee80211/scatterwalk.c | 117 ----- .../staging/rtl8192u/ieee80211/scatterwalk.h | 51 -- drivers/staging/rtl8192u/r819xU_HTGen.h | 12 - drivers/staging/rtl8192u/r819xU_HTType.h | 379 -------------- 16 files changed, 2677 deletions(-) delete mode 100644 drivers/staging/rtl8192u/ieee80211/EndianFree.h delete mode 100644 drivers/staging/rtl8192u/ieee80211/aes.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/arc4.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/autoload.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/cipher.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/compress.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/crypto_compat.h delete mode 100644 drivers/staging/rtl8192u/ieee80211/digest.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/internal.h delete mode 100644 drivers/staging/rtl8192u/ieee80211/michael_mic.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/proc.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/rtl_crypto.h delete mode 100644 drivers/staging/rtl8192u/ieee80211/scatterwalk.c delete mode 100644 drivers/staging/rtl8192u/ieee80211/scatterwalk.h delete mode 100644 drivers/staging/rtl8192u/r819xU_HTGen.h delete mode 100644 drivers/staging/rtl8192u/r819xU_HTType.h diff --git a/drivers/staging/rtl8192u/ieee80211/EndianFree.h b/drivers/staging/rtl8192u/ieee80211/EndianFree.h deleted file mode 100644 index dc85fb913dc2..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/EndianFree.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef __INC_ENDIANFREE_H -#define __INC_ENDIANFREE_H - -/* - * Call endian free function when - * 1. Read/write packet content. - * 2. Before write integer to IO. - * 3. After read integer from IO. - */ - -#define __MACHINE_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define __MACHINE_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net, ppc */ - -#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN - -#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN -// Convert data -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) ((u16)(_val)) -#define EF4Byte(_val) ((u32)(_val)) - -#else -// Convert data -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) -#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\ - ((((u32)(_val))&0x0000ff00)<<8)|\ - ((((u32)(_val))&0x00ff0000)>>8)|\ - ((((u32)(_val))&0xff000000)>>24)) -#endif - -// Read data from memory -#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr))) -#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr))) -#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr))) - -// Write data to memory -#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val) -#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val) -#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val) -// Convert Host system specific byte ording (litten or big endia) to Network byte ording (big endian). -// 2006.05.07, by rcnjko. -#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN -#define H2N1BYTE(_val) ((u8)(_val)) -#define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ - ((((u16)(_val))&0xff00)>>8)) -#define H2N4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\ - ((((u32)(_val))&0x0000ff00)<<8) |\ - ((((u32)(_val))&0x00ff0000)>>8) |\ - ((((u32)(_val))&0xff000000)>>24)) -#else -#define H2N1BYTE(_val) ((u8)(_val)) -#define H2N2BYTE(_val) ((u16)(_val)) -#define H2N4BYTE(_val) ((u32)(_val)) -#endif - -// Convert from Network byte ording (big endian) to Host system specific byte ording (litten or big endia). -// 2006.05.07, by rcnjko. -#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN -#define N2H1BYTE(_val) ((u8)(_val)) -#define N2H2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ - ((((u16)(_val))&0xff00)>>8)) -#define N2H4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\ - ((((u32)(_val))&0x0000ff00)<<8) |\ - ((((u32)(_val))&0x00ff0000)>>8) |\ - ((((u32)(_val))&0xff000000)>>24)) -#else -#define N2H1BYTE(_val) ((u8)(_val)) -#define N2H2BYTE(_val) ((u16)(_val)) -#define N2H4BYTE(_val) ((u32)(_val)) -#endif - -// -// Example: -// BIT_LEN_MASK_32(0) => 0x00000000 -// BIT_LEN_MASK_32(1) => 0x00000001 -// BIT_LEN_MASK_32(2) => 0x00000003 -// BIT_LEN_MASK_32(32) => 0xFFFFFFFF -// -#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen))) -// -// Example: -// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003 -// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000 -// -#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) - -// -// Description: -// Return 4-byte value in host byte ordering from -// 4-byte pointer in litten-endian system. -// -#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart)))) - -// -// Description: -// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to -// 4-byte value in host byte ordering. -// -#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ - ( \ - ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \ - & \ - BIT_LEN_MASK_32(__BitLen) \ - ) - -// -// Description: -// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering -// and return the result in 4-byte value in host byte ordering. -// -#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ - ( \ - LE_P4BYTE_TO_HOST_4BYTE(__pStart) \ - & \ - ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \ - ) - -// -// Description: -// Set subfield of little-endian 4-byte value to specified value. -// -#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \ - *((u32 *)(__pStart)) = \ - EF4Byte( \ - LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \ - ); - - -#define BIT_LEN_MASK_16(__BitLen) \ - (0xFFFF >> (16 - (__BitLen))) - -#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \ - (BIT_LEN_MASK_16(__BitLen) << (__BitOffset)) - -#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ - (EF2Byte(*((u16 *)(__pStart)))) - -#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ - ( \ - ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \ - & \ - BIT_LEN_MASK_16(__BitLen) \ - ) - -#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ - ( \ - LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ - & \ - ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \ - ) - -#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \ - *((u16 *)(__pStart)) = \ - EF2Byte( \ - LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \ - ); - -#define BIT_LEN_MASK_8(__BitLen) \ - (0xFF >> (8 - (__BitLen))) - -#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \ - (BIT_LEN_MASK_8(__BitLen) << (__BitOffset)) - -#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ - (EF1Byte(*((u8 *)(__pStart)))) - -#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ - ( \ - ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \ - & \ - BIT_LEN_MASK_8(__BitLen) \ - ) - -#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ - ( \ - LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ - & \ - ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \ - ) - -#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ - *((u8 *)(__pStart)) = \ - EF1Byte( \ - LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \ - ); - -#endif // #ifndef __INC_ENDIANFREE_H diff --git a/drivers/staging/rtl8192u/ieee80211/aes.c b/drivers/staging/rtl8192u/ieee80211/aes.c deleted file mode 100644 index abc1023cef65..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/aes.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Cryptographic API. - * - * AES Cipher Algorithm. - * - * Based on Brian Gladman's code. - * - * Linux developers: - * Alexander Kjeldaas - * Herbert Valerio Riedel - * Kyle McMartin - * Adam J. Richter (conversion to 2.5 API). - * - * 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. - * - * --------------------------------------------------------------------------- - * Copyright (c) 2002, Dr Brian Gladman , Worcester, UK. - * All rights reserved. - * - * LICENSE TERMS - * - * The free distribution and use of this software in both source and binary - * form is allowed (with or without changes) provided that: - * - * 1. distributions of this source code include the above copyright - * notice, this list of conditions and the following disclaimer; - * - * 2. distributions in binary form include the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other associated materials; - * - * 3. the copyright holder's name is not used to endorse products - * built using this software without specific written permission. - * - * ALTERNATIVELY, provided that this notice is retained in full, this product - * may be distributed under the terms of the GNU General Public License (GPL), - * in which case the provisions of the GPL apply INSTEAD OF those given above. - * - * DISCLAIMER - * - * This software is provided 'as is' with no explicit or implied warranties - * in respect of its properties, including, but not limited to, correctness - * and/or fitness for purpose. - * --------------------------------------------------------------------------- - */ - -/* Some changes from the Gladman version: - s/RIJNDAEL(e_key)/E_KEY/g - s/RIJNDAEL(d_key)/D_KEY/g -*/ - -#include -#include -#include -#include -//#include -#include "rtl_crypto.h" -#include - -#define AES_MIN_KEY_SIZE 16 -#define AES_MAX_KEY_SIZE 32 - -#define AES_BLOCK_SIZE 16 - -static inline -u32 generic_rotr32 (const u32 x, const unsigned bits) -{ - const unsigned n = bits % 32; - return (x >> n) | (x << (32 - n)); -} - -static inline -u32 generic_rotl32 (const u32 x, const unsigned bits) -{ - const unsigned n = bits % 32; - return (x << n) | (x >> (32 - n)); -} - -#define rotl generic_rotl32 -#define rotr generic_rotr32 - -/* - * #define byte(x, nr) ((unsigned char)((x) >> (nr*8))) - */ -inline static u8 -byte(const u32 x, const unsigned n) -{ - return x >> (n << 3); -} - -#define u32_in(x) le32_to_cpu(*(const u32 *)(x)) -#define u32_out(to, from) (*(u32 *)(to) = cpu_to_le32(from)) - -struct aes_ctx { - int key_length; - u32 E[60]; - u32 D[60]; -}; - -#define E_KEY ctx->E -#define D_KEY ctx->D - -static u8 pow_tab[256] __initdata; -static u8 log_tab[256] __initdata; -static u8 sbx_tab[256] __initdata; -static u8 isb_tab[256] __initdata; -static u32 rco_tab[10]; -static u32 ft_tab[4][256]; -static u32 it_tab[4][256]; - -static u32 fl_tab[4][256]; -static u32 il_tab[4][256]; - -static inline u8 __init -f_mult (u8 a, u8 b) -{ - u8 aa = log_tab[a], cc = aa + log_tab[b]; - - return pow_tab[cc + (cc < aa ? 1 : 0)]; -} - -#define ff_mult(a,b) (a && b ? f_mult(a, b) : 0) - -#define f_rn(bo, bi, n, k) \ - bo[n] = ft_tab[0][byte(bi[n],0)] ^ \ - ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ - ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) - -#define i_rn(bo, bi, n, k) \ - bo[n] = it_tab[0][byte(bi[n],0)] ^ \ - it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ - it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) - -#define ls_box(x) \ - ( fl_tab[0][byte(x, 0)] ^ \ - fl_tab[1][byte(x, 1)] ^ \ - fl_tab[2][byte(x, 2)] ^ \ - fl_tab[3][byte(x, 3)] ) - -#define f_rl(bo, bi, n, k) \ - bo[n] = fl_tab[0][byte(bi[n],0)] ^ \ - fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ - fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) - -#define i_rl(bo, bi, n, k) \ - bo[n] = il_tab[0][byte(bi[n],0)] ^ \ - il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ - il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) - -static void __init -gen_tabs (void) -{ - u32 i, t; - u8 p, q; - - /* log and power tables for GF(2**8) finite field with - 0x011b as modular polynomial - the simplest primitive - root is 0x03, used here to generate the tables */ - - for (i = 0, p = 1; i < 256; ++i) { - pow_tab[i] = (u8) p; - log_tab[p] = (u8) i; - - p ^= (p << 1) ^ (p & 0x80 ? 0x01b : 0); - } - - log_tab[1] = 0; - - for (i = 0, p = 1; i < 10; ++i) { - rco_tab[i] = p; - - p = (p << 1) ^ (p & 0x80 ? 0x01b : 0); - } - - for (i = 0; i < 256; ++i) { - p = (i ? pow_tab[255 - log_tab[i]] : 0); - q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2)); - p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2)); - sbx_tab[i] = p; - isb_tab[p] = (u8) i; - } - - for (i = 0; i < 256; ++i) { - p = sbx_tab[i]; - - t = p; - fl_tab[0][i] = t; - fl_tab[1][i] = rotl (t, 8); - fl_tab[2][i] = rotl (t, 16); - fl_tab[3][i] = rotl (t, 24); - - t = ((u32) ff_mult (2, p)) | - ((u32) p << 8) | - ((u32) p << 16) | ((u32) ff_mult (3, p) << 24); - - ft_tab[0][i] = t; - ft_tab[1][i] = rotl (t, 8); - ft_tab[2][i] = rotl (t, 16); - ft_tab[3][i] = rotl (t, 24); - - p = isb_tab[i]; - - t = p; - il_tab[0][i] = t; - il_tab[1][i] = rotl (t, 8); - il_tab[2][i] = rotl (t, 16); - il_tab[3][i] = rotl (t, 24); - - t = ((u32) ff_mult (14, p)) | - ((u32) ff_mult (9, p) << 8) | - ((u32) ff_mult (13, p) << 16) | - ((u32) ff_mult (11, p) << 24); - - it_tab[0][i] = t; - it_tab[1][i] = rotl (t, 8); - it_tab[2][i] = rotl (t, 16); - it_tab[3][i] = rotl (t, 24); - } -} - -#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b) - -#define imix_col(y,x) \ - u = star_x(x); \ - v = star_x(u); \ - w = star_x(v); \ - t = w ^ (x); \ - (y) = u ^ v ^ w; \ - (y) ^= rotr(u ^ t, 8) ^ \ - rotr(v ^ t, 16) ^ \ - rotr(t,24) - -/* initialise the key schedule from the user supplied key */ - -#define loop4(i) \ -{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \ - t ^= E_KEY[4 * i]; E_KEY[4 * i + 4] = t; \ - t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t; \ - t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t; \ - t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t; \ -} - -#define loop6(i) \ -{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \ - t ^= E_KEY[6 * i]; E_KEY[6 * i + 6] = t; \ - t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t; \ - t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t; \ - t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t; \ - t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t; \ - t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t; \ -} - -#define loop8(i) \ -{ t = rotr(t, 8); ; t = ls_box(t) ^ rco_tab[i]; \ - t ^= E_KEY[8 * i]; E_KEY[8 * i + 8] = t; \ - t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t; \ - t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t; \ - t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t; \ - t = E_KEY[8 * i + 4] ^ ls_box(t); \ - E_KEY[8 * i + 12] = t; \ - t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t; \ - t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t; \ - t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \ -} - -static int -aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags) -{ - struct aes_ctx *ctx = ctx_arg; - u32 i, t, u, v, w; - - if (key_len != 16 && key_len != 24 && key_len != 32) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - - ctx->key_length = key_len; - - E_KEY[0] = u32_in (in_key); - E_KEY[1] = u32_in (in_key + 4); - E_KEY[2] = u32_in (in_key + 8); - E_KEY[3] = u32_in (in_key + 12); - - switch (key_len) { - case 16: - t = E_KEY[3]; - for (i = 0; i < 10; ++i) - loop4 (i); - break; - - case 24: - E_KEY[4] = u32_in (in_key + 16); - t = E_KEY[5] = u32_in (in_key + 20); - for (i = 0; i < 8; ++i) - loop6 (i); - break; - - case 32: - E_KEY[4] = u32_in (in_key + 16); - E_KEY[5] = u32_in (in_key + 20); - E_KEY[6] = u32_in (in_key + 24); - t = E_KEY[7] = u32_in (in_key + 28); - for (i = 0; i < 7; ++i) - loop8 (i); - break; - } - - D_KEY[0] = E_KEY[0]; - D_KEY[1] = E_KEY[1]; - D_KEY[2] = E_KEY[2]; - D_KEY[3] = E_KEY[3]; - - for (i = 4; i < key_len + 24; ++i) { - imix_col (D_KEY[i], E_KEY[i]); - } - - return 0; -} - -/* encrypt a block of text */ - -#define f_nround(bo, bi, k) \ - f_rn(bo, bi, 0, k); \ - f_rn(bo, bi, 1, k); \ - f_rn(bo, bi, 2, k); \ - f_rn(bo, bi, 3, k); \ - k += 4 - -#define f_lround(bo, bi, k) \ - f_rl(bo, bi, 0, k); \ - f_rl(bo, bi, 1, k); \ - f_rl(bo, bi, 2, k); \ - f_rl(bo, bi, 3, k) - -static void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in) -{ - const struct aes_ctx *ctx = ctx_arg; - u32 b0[4], b1[4]; - const u32 *kp = E_KEY + 4; - - b0[0] = u32_in (in) ^ E_KEY[0]; - b0[1] = u32_in (in + 4) ^ E_KEY[1]; - b0[2] = u32_in (in + 8) ^ E_KEY[2]; - b0[3] = u32_in (in + 12) ^ E_KEY[3]; - - if (ctx->key_length > 24) { - f_nround (b1, b0, kp); - f_nround (b0, b1, kp); - } - - if (ctx->key_length > 16) { - f_nround (b1, b0, kp); - f_nround (b0, b1, kp); - } - - f_nround (b1, b0, kp); - f_nround (b0, b1, kp); - f_nround (b1, b0, kp); - f_nround (b0, b1, kp); - f_nround (b1, b0, kp); - f_nround (b0, b1, kp); - f_nround (b1, b0, kp); - f_nround (b0, b1, kp); - f_nround (b1, b0, kp); - f_lround (b0, b1, kp); - - u32_out (out, b0[0]); - u32_out (out + 4, b0[1]); - u32_out (out + 8, b0[2]); - u32_out (out + 12, b0[3]); -} - -/* decrypt a block of text */ - -#define i_nround(bo, bi, k) \ - i_rn(bo, bi, 0, k); \ - i_rn(bo, bi, 1, k); \ - i_rn(bo, bi, 2, k); \ - i_rn(bo, bi, 3, k); \ - k -= 4 - -#define i_lround(bo, bi, k) \ - i_rl(bo, bi, 0, k); \ - i_rl(bo, bi, 1, k); \ - i_rl(bo, bi, 2, k); \ - i_rl(bo, bi, 3, k) - -static void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in) -{ - const struct aes_ctx *ctx = ctx_arg; - u32 b0[4], b1[4]; - const int key_len = ctx->key_length; - const u32 *kp = D_KEY + key_len + 20; - - b0[0] = u32_in (in) ^ E_KEY[key_len + 24]; - b0[1] = u32_in (in + 4) ^ E_KEY[key_len + 25]; - b0[2] = u32_in (in + 8) ^ E_KEY[key_len + 26]; - b0[3] = u32_in (in + 12) ^ E_KEY[key_len + 27]; - - if (key_len > 24) { - i_nround (b1, b0, kp); - i_nround (b0, b1, kp); - } - - if (key_len > 16) { - i_nround (b1, b0, kp); - i_nround (b0, b1, kp); - } - - i_nround (b1, b0, kp); - i_nround (b0, b1, kp); - i_nround (b1, b0, kp); - i_nround (b0, b1, kp); - i_nround (b1, b0, kp); - i_nround (b0, b1, kp); - i_nround (b1, b0, kp); - i_nround (b0, b1, kp); - i_nround (b1, b0, kp); - i_lround (b0, b1, kp); - - u32_out (out, b0[0]); - u32_out (out + 4, b0[1]); - u32_out (out + 8, b0[2]); - u32_out (out + 12, b0[3]); -} - - -static struct crypto_alg aes_alg = { - .cra_name = "aes", - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), - .cra_u = { - .cipher = { - .cia_min_keysize = AES_MIN_KEY_SIZE, - .cia_max_keysize = AES_MAX_KEY_SIZE, - .cia_setkey = aes_set_key, - .cia_encrypt = aes_encrypt, - .cia_decrypt = aes_decrypt - } - } -}; - -static int __init aes_init(void) -{ - gen_tabs(); - return crypto_register_alg(&aes_alg); -} - -static void __exit aes_fini(void) -{ - crypto_unregister_alg(&aes_alg); -} - -module_init(aes_init); -module_exit(aes_fini); - -MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm"); -MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/staging/rtl8192u/ieee80211/arc4.c b/drivers/staging/rtl8192u/ieee80211/arc4.c deleted file mode 100644 index b790e9ad104c..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/arc4.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Cryptographic API - * - * ARC4 Cipher Algorithm - * - * Jon Oberheide - * - * 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 "rtl_crypto.h" - -#define ARC4_MIN_KEY_SIZE 1 -#define ARC4_MAX_KEY_SIZE 256 -#define ARC4_BLOCK_SIZE 1 - -struct arc4_ctx { - u8 S[256]; - u8 x, y; -}; - -static int arc4_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags) -{ - struct arc4_ctx *ctx = ctx_arg; - int i, j = 0, k = 0; - - ctx->x = 1; - ctx->y = 0; - - for(i = 0; i < 256; i++) - ctx->S[i] = i; - - for(i = 0; i < 256; i++) - { - u8 a = ctx->S[i]; - j = (j + in_key[k] + a) & 0xff; - ctx->S[i] = ctx->S[j]; - ctx->S[j] = a; - if((unsigned int)++k >= key_len) - k = 0; - } - - return 0; -} - -static void arc4_crypt(void *ctx_arg, u8 *out, const u8 *in) -{ - struct arc4_ctx *ctx = ctx_arg; - - u8 *const S = ctx->S; - u8 x = ctx->x; - u8 y = ctx->y; - u8 a, b; - - a = S[x]; - y = (y + a) & 0xff; - b = S[y]; - S[x] = b; - S[y] = a; - x = (x + 1) & 0xff; - *out++ = *in ^ S[(a + b) & 0xff]; - - ctx->x = x; - ctx->y = y; -} - -static struct crypto_alg arc4_alg = { - .cra_name = "arc4", - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = ARC4_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct arc4_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(arc4_alg.cra_list), - .cra_u = { .cipher = { - .cia_min_keysize = ARC4_MIN_KEY_SIZE, - .cia_max_keysize = ARC4_MAX_KEY_SIZE, - .cia_setkey = arc4_set_key, - .cia_encrypt = arc4_crypt, - .cia_decrypt = arc4_crypt } } -}; - -static int __init arc4_init(void) -{ - return crypto_register_alg(&arc4_alg); -} - - -static void __exit arc4_exit(void) -{ - crypto_unregister_alg(&arc4_alg); -} - -module_init(arc4_init); -module_exit(arc4_exit); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("ARC4 Cipher Algorithm"); -MODULE_AUTHOR("Jon Oberheide "); diff --git a/drivers/staging/rtl8192u/ieee80211/autoload.c b/drivers/staging/rtl8192u/ieee80211/autoload.c deleted file mode 100644 index c97756f3b2ea..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/autoload.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Cryptographic API. - * - * Algorithm autoloader. - * - * Copyright (c) 2002 James Morris - * - * 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 "kmap_types.h" - -#include -//#include -#include "rtl_crypto.h" -#include -#include -#include "internal.h" - -/* - * A far more intelligent version of this is planned. For now, just - * try an exact match on the name of the algorithm. - */ -void crypto_alg_autoload(const char *name) -{ - request_module(name); -} - -struct crypto_alg *crypto_alg_mod_lookup(const char *name) -{ - struct crypto_alg *alg = crypto_alg_lookup(name); - if (alg == NULL) { - crypto_alg_autoload(name); - alg = crypto_alg_lookup(name); - } - return alg; -} diff --git a/drivers/staging/rtl8192u/ieee80211/cipher.c b/drivers/staging/rtl8192u/ieee80211/cipher.c deleted file mode 100644 index d47345c4adcf..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/cipher.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Cryptographic API. - * - * Cipher operations. - * - * Copyright (c) 2002 James Morris - * - * 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 "rtl_crypto.h" -#include -#include -#include -#include -#include "internal.h" -#include "scatterwalk.h" - -typedef void (cryptfn_t)(void *, u8 *, const u8 *); -typedef void (procfn_t)(struct crypto_tfm *, u8 *, - u8*, cryptfn_t, int enc, void *, int); - -static inline void xor_64(u8 *a, const u8 *b) -{ - ((u32 *)a)[0] ^= ((u32 *)b)[0]; - ((u32 *)a)[1] ^= ((u32 *)b)[1]; -} - -static inline void xor_128(u8 *a, const u8 *b) -{ - ((u32 *)a)[0] ^= ((u32 *)b)[0]; - ((u32 *)a)[1] ^= ((u32 *)b)[1]; - ((u32 *)a)[2] ^= ((u32 *)b)[2]; - ((u32 *)a)[3] ^= ((u32 *)b)[3]; -} - - -/* - * Generic encrypt/decrypt wrapper for ciphers, handles operations across - * multiple page boundaries by using temporary blocks. In user context, - * the kernel is given a chance to schedule us once per block. - */ -static int crypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, cryptfn_t crfn, - procfn_t prfn, int enc, void *info) -{ - struct scatter_walk walk_in, walk_out; - const unsigned int bsize = crypto_tfm_alg_blocksize(tfm); - u8 tmp_src[bsize]; - u8 tmp_dst[bsize]; - - if (!nbytes) - return 0; - - if (nbytes % bsize) { - tfm->crt_flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN; - return -EINVAL; - } - - scatterwalk_start(&walk_in, src); - scatterwalk_start(&walk_out, dst); - - for(;;) { - u8 *src_p, *dst_p; - int in_place; - - scatterwalk_map(&walk_in); - scatterwalk_map(&walk_out); - src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src); - dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst); - in_place = scatterwalk_samebuf(&walk_in, &walk_out, - src_p, dst_p); - - nbytes -= bsize; - - scatterwalk_copychunks(src_p, &walk_in, bsize, 0); - - prfn(tfm, dst_p, src_p, crfn, enc, info, in_place); - - scatterwalk_done(&walk_in, nbytes); - - scatterwalk_copychunks(dst_p, &walk_out, bsize, 1); - scatterwalk_done(&walk_out, nbytes); - - if (!nbytes) - return 0; - - crypto_yield(tfm); - } -} - -static void cbc_process(struct crypto_tfm *tfm, u8 *dst, u8 *src, - cryptfn_t fn, int enc, void *info, int in_place) -{ - u8 *iv = info; - - /* Null encryption */ - if (!iv) - return; - - if (enc) { - tfm->crt_u.cipher.cit_xor_block(iv, src); - fn(crypto_tfm_ctx(tfm), dst, iv); - memcpy(iv, dst, crypto_tfm_alg_blocksize(tfm)); - } else { - u8 stack[in_place ? crypto_tfm_alg_blocksize(tfm) : 0]; - u8 *buf = in_place ? stack : dst; - - fn(crypto_tfm_ctx(tfm), buf, src); - tfm->crt_u.cipher.cit_xor_block(buf, iv); - memcpy(iv, src, crypto_tfm_alg_blocksize(tfm)); - if (buf != dst) - memcpy(dst, buf, crypto_tfm_alg_blocksize(tfm)); - } -} - -static void ecb_process(struct crypto_tfm *tfm, u8 *dst, u8 *src, - cryptfn_t fn, int enc, void *info, int in_place) -{ - fn(crypto_tfm_ctx(tfm), dst, src); -} - -static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) -{ - struct cipher_alg *cia = &tfm->__crt_alg->cra_cipher; - - if (keylen < cia->cia_min_keysize || keylen > cia->cia_max_keysize) { - tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } else - return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen, - &tfm->crt_flags); -} - -static int ecb_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - return crypt(tfm, dst, src, nbytes, - tfm->__crt_alg->cra_cipher.cia_encrypt, - ecb_process, 1, NULL); -} - -static int ecb_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) -{ - return crypt(tfm, dst, src, nbytes, - tfm->__crt_alg->cra_cipher.cia_decrypt, - ecb_process, 1, NULL); -} - -static int cbc_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) -{ - return crypt(tfm, dst, src, nbytes, - tfm->__crt_alg->cra_cipher.cia_encrypt, - cbc_process, 1, tfm->crt_cipher.cit_iv); -} - -static int cbc_encrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) -{ - return crypt(tfm, dst, src, nbytes, - tfm->__crt_alg->cra_cipher.cia_encrypt, - cbc_process, 1, iv); -} - -static int cbc_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) -{ - return crypt(tfm, dst, src, nbytes, - tfm->__crt_alg->cra_cipher.cia_decrypt, - cbc_process, 0, tfm->crt_cipher.cit_iv); -} - -static int cbc_decrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) -{ - return crypt(tfm, dst, src, nbytes, - tfm->__crt_alg->cra_cipher.cia_decrypt, - cbc_process, 0, iv); -} - -static int nocrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) -{ - return -ENOSYS; -} - -static int nocrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) -{ - return -ENOSYS; -} - -int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags) -{ - u32 mode = flags & CRYPTO_TFM_MODE_MASK; - - tfm->crt_cipher.cit_mode = mode ? mode : CRYPTO_TFM_MODE_ECB; - if (flags & CRYPTO_TFM_REQ_WEAK_KEY) - tfm->crt_flags = CRYPTO_TFM_REQ_WEAK_KEY; - - return 0; -} - -int crypto_init_cipher_ops(struct crypto_tfm *tfm) -{ - int ret = 0; - struct cipher_tfm *ops = &tfm->crt_cipher; - - ops->cit_setkey = setkey; - - switch (tfm->crt_cipher.cit_mode) { - case CRYPTO_TFM_MODE_ECB: - ops->cit_encrypt = ecb_encrypt; - ops->cit_decrypt = ecb_decrypt; - break; - - case CRYPTO_TFM_MODE_CBC: - ops->cit_encrypt = cbc_encrypt; - ops->cit_decrypt = cbc_decrypt; - ops->cit_encrypt_iv = cbc_encrypt_iv; - ops->cit_decrypt_iv = cbc_decrypt_iv; - break; - - case CRYPTO_TFM_MODE_CFB: - ops->cit_encrypt = nocrypt; - ops->cit_decrypt = nocrypt; - ops->cit_encrypt_iv = nocrypt_iv; - ops->cit_decrypt_iv = nocrypt_iv; - break; - - case CRYPTO_TFM_MODE_CTR: - ops->cit_encrypt = nocrypt; - ops->cit_decrypt = nocrypt; - ops->cit_encrypt_iv = nocrypt_iv; - ops->cit_decrypt_iv = nocrypt_iv; - break; - - default: - BUG(); - } - - if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) { - - switch (crypto_tfm_alg_blocksize(tfm)) { - case 8: - ops->cit_xor_block = xor_64; - break; - - case 16: - ops->cit_xor_block = xor_128; - break; - - default: - printk(KERN_WARNING "%s: block size %u not supported\n", - crypto_tfm_alg_name(tfm), - crypto_tfm_alg_blocksize(tfm)); - ret = -EINVAL; - goto out; - } - - ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm); - ops->cit_iv = kmalloc(ops->cit_ivsize, GFP_KERNEL); - if (ops->cit_iv == NULL) - ret = -ENOMEM; - } - -out: - return ret; -} - -void crypto_exit_cipher_ops(struct crypto_tfm *tfm) -{ - kfree(tfm->crt_cipher.cit_iv); -} diff --git a/drivers/staging/rtl8192u/ieee80211/compress.c b/drivers/staging/rtl8192u/ieee80211/compress.c deleted file mode 100644 index 5416ab63a738..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/compress.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Cryptographic API. - * - * Compression operations. - * - * Copyright (c) 2002 James Morris - * - * 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 "rtl_crypto.h" -#include -#include -#include -#include "internal.h" - -static int crypto_compress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) -{ - return tfm->__crt_alg->cra_compress.coa_compress(crypto_tfm_ctx(tfm), - src, slen, dst, - dlen); -} - -static int crypto_decompress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) -{ - return tfm->__crt_alg->cra_compress.coa_decompress(crypto_tfm_ctx(tfm), - src, slen, dst, - dlen); -} - -int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags) -{ - return flags ? -EINVAL : 0; -} - -int crypto_init_compress_ops(struct crypto_tfm *tfm) -{ - int ret = 0; - struct compress_tfm *ops = &tfm->crt_compress; - - ret = tfm->__crt_alg->cra_compress.coa_init(crypto_tfm_ctx(tfm)); - if (ret) - goto out; - - ops->cot_compress = crypto_compress; - ops->cot_decompress = crypto_decompress; - -out: - return ret; -} - -void crypto_exit_compress_ops(struct crypto_tfm *tfm) -{ - tfm->__crt_alg->cra_compress.coa_exit(crypto_tfm_ctx(tfm)); -} diff --git a/drivers/staging/rtl8192u/ieee80211/crypto_compat.h b/drivers/staging/rtl8192u/ieee80211/crypto_compat.h deleted file mode 100644 index 2ba374a64178..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/crypto_compat.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Header file to maintain compatibility among different kernel versions. - * - * Copyright (c) 2004-2006 - * - * 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 - -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_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); -} - - struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags) -{ - struct crypto_tfm *tfm = NULL; - int err; - printk("call crypto_alloc_tfm!!!\n"); - do { - struct crypto_alg *alg; - - alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC); - err = PTR_ERR(alg); - if (IS_ERR(alg)) - continue; - - tfm = __crypto_alloc_tfm(alg, flags); - err = 0; - if (IS_ERR(tfm)) { - crypto_mod_put(alg); - err = PTR_ERR(tfm); - tfm = NULL; - } - } while (err == -EAGAIN && !signal_pending(current)); - - return tfm; -} -//EXPORT_SYMBOL_GPL(crypto_alloc_tfm); -//EXPORT_SYMBOL_GPL(crypto_free_tfm); diff --git a/drivers/staging/rtl8192u/ieee80211/digest.c b/drivers/staging/rtl8192u/ieee80211/digest.c deleted file mode 100644 index 05e7497fd106..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/digest.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Cryptographic API. - * - * Digest operations. - * - * Copyright (c) 2002 James Morris - * - * 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 "rtl_crypto.h" -#include -#include -#include -#include -#include "internal.h" - -static void init(struct crypto_tfm *tfm) -{ - tfm->__crt_alg->cra_digest.dia_init(crypto_tfm_ctx(tfm)); -} - -static void update(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg) -{ - unsigned int i; - - for (i = 0; i < nsg; i++) { - - struct page *pg = sg[i].page; - unsigned int offset = sg[i].offset; - unsigned int l = sg[i].length; - - do { - unsigned int bytes_from_page = min(l, ((unsigned int) - (PAGE_SIZE)) - - offset); - char *p = kmap_atomic(pg) + offset; - - tfm->__crt_alg->cra_digest.dia_update - (crypto_tfm_ctx(tfm), p, - bytes_from_page); - kunmap_atomic(p); - crypto_yield(tfm); - offset = 0; - pg++; - l -= bytes_from_page; - } while (l > 0); - } -} - -static void final(struct crypto_tfm *tfm, u8 *out) -{ - tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out); -} - -static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) -{ - u32 flags; - if (tfm->__crt_alg->cra_digest.dia_setkey == NULL) - return -ENOSYS; - return tfm->__crt_alg->cra_digest.dia_setkey(crypto_tfm_ctx(tfm), - key, keylen, &flags); -} - -static void digest(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg, u8 *out) -{ - unsigned int i; - - tfm->crt_digest.dit_init(tfm); - - for (i = 0; i < nsg; i++) { - char *p = kmap_atomic(sg[i].page) + sg[i].offset; - tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm), - p, sg[i].length); - kunmap_atomic(p); - crypto_yield(tfm); - } - crypto_digest_final(tfm, out); -} - -int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags) -{ - return flags ? -EINVAL : 0; -} - -int crypto_init_digest_ops(struct crypto_tfm *tfm) -{ - struct digest_tfm *ops = &tfm->crt_digest; - - ops->dit_init = init; - ops->dit_update = update; - ops->dit_final = final; - ops->dit_digest = digest; - ops->dit_setkey = setkey; - - return crypto_alloc_hmac_block(tfm); -} - -void crypto_exit_digest_ops(struct crypto_tfm *tfm) -{ - crypto_free_hmac_block(tfm); -} diff --git a/drivers/staging/rtl8192u/ieee80211/internal.h b/drivers/staging/rtl8192u/ieee80211/internal.h deleted file mode 100644 index 6f54cfe8a467..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/internal.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Cryptographic API. - * - * Copyright (c) 2002 James Morris - * - * 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 _CRYPTO_INTERNAL_H -#define _CRYPTO_INTERNAL_H - - -//#include -#include "rtl_crypto.h" -#include -#include -#include -#include -#include -#include - - -static inline void crypto_yield(struct crypto_tfm *tfm) -{ - if (!in_softirq()) - cond_resched(); -} - -static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm) -{ - return (void *)&tfm[1]; -} - -struct crypto_alg *crypto_alg_lookup(const char *name); - -#ifdef CONFIG_KMOD -void crypto_alg_autoload(const char *name); -struct crypto_alg *crypto_alg_mod_lookup(const char *name); -#else -static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) -{ - return crypto_alg_lookup(name); -} -#endif - -#ifdef CONFIG_CRYPTO_HMAC -int crypto_alloc_hmac_block(struct crypto_tfm *tfm); -void crypto_free_hmac_block(struct crypto_tfm *tfm); -#else -static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm) -{ - return 0; -} - -static inline void crypto_free_hmac_block(struct crypto_tfm *tfm) -{ } -#endif - -#ifdef CONFIG_PROC_FS -void __init crypto_init_proc(void); -#else -static inline void crypto_init_proc(void) -{ } -#endif - -int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); -int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags); -int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags); - -int crypto_init_digest_ops(struct crypto_tfm *tfm); -int crypto_init_cipher_ops(struct crypto_tfm *tfm); -int crypto_init_compress_ops(struct crypto_tfm *tfm); - -void crypto_exit_digest_ops(struct crypto_tfm *tfm); -void crypto_exit_cipher_ops(struct crypto_tfm *tfm); -void crypto_exit_compress_ops(struct crypto_tfm *tfm); - -#endif /* _CRYPTO_INTERNAL_H */ diff --git a/drivers/staging/rtl8192u/ieee80211/michael_mic.c b/drivers/staging/rtl8192u/ieee80211/michael_mic.c deleted file mode 100644 index df256e487c20..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/michael_mic.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Cryptographic API - * - * Michael MIC (IEEE 802.11i/TKIP) keyed digest - * - * Copyright (c) 2004 Jouni Malinen - * - * 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. - */ - -#include -#include -#include -//#include -#include "rtl_crypto.h" - - -struct michael_mic_ctx { - u8 pending[4]; - size_t pending_len; - - u32 l, r; -}; - - -static inline u32 rotl(u32 val, int bits) -{ - return (val << bits) | (val >> (32 - bits)); -} - - -static inline u32 rotr(u32 val, int bits) -{ - return (val >> bits) | (val << (32 - bits)); -} - - -static inline u32 xswap(u32 val) -{ - return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8); -} - - -#define michael_block(l, r) \ -do { \ - r ^= rotl(l, 17); \ - l += r; \ - r ^= xswap(l); \ - l += r; \ - r ^= rotl(l, 3); \ - l += r; \ - r ^= rotr(l, 2); \ - l += r; \ -} while (0) - - -static inline u32 get_le32(const u8 *p) -{ - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); -} - - -static inline void put_le32(u8 *p, u32 v) -{ - p[0] = v; - p[1] = v >> 8; - p[2] = v >> 16; - p[3] = v >> 24; -} - - -static void michael_init(void *ctx) -{ - struct michael_mic_ctx *mctx = ctx; - mctx->pending_len = 0; -} - - -static void michael_update(void *ctx, const u8 *data, unsigned int len) -{ - struct michael_mic_ctx *mctx = ctx; - - if (mctx->pending_len) { - int flen = 4 - mctx->pending_len; - if (flen > len) - flen = len; - memcpy(&mctx->pending[mctx->pending_len], data, flen); - mctx->pending_len += flen; - data += flen; - len -= flen; - - if (mctx->pending_len < 4) - return; - - mctx->l ^= get_le32(mctx->pending); - michael_block(mctx->l, mctx->r); - mctx->pending_len = 0; - } - - while (len >= 4) { - mctx->l ^= get_le32(data); - michael_block(mctx->l, mctx->r); - data += 4; - len -= 4; - } - - if (len > 0) { - mctx->pending_len = len; - memcpy(mctx->pending, data, len); - } -} - - -static void michael_final(void *ctx, u8 *out) -{ - struct michael_mic_ctx *mctx = ctx; - u8 *data = mctx->pending; - - /* Last block and padding (0x5a, 4..7 x 0) */ - switch (mctx->pending_len) { - case 0: - mctx->l ^= 0x5a; - break; - case 1: - mctx->l ^= data[0] | 0x5a00; - break; - case 2: - mctx->l ^= data[0] | (data[1] << 8) | 0x5a0000; - break; - case 3: - mctx->l ^= data[0] | (data[1] << 8) | (data[2] << 16) | - 0x5a000000; - break; - } - michael_block(mctx->l, mctx->r); - /* l ^= 0; */ - michael_block(mctx->l, mctx->r); - - put_le32(out, mctx->l); - put_le32(out + 4, mctx->r); -} - - -static int michael_setkey(void *ctx, const u8 *key, unsigned int keylen, - u32 *flags) -{ - struct michael_mic_ctx *mctx = ctx; - if (keylen != 8) { - if (flags) - *flags = CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - mctx->l = get_le32(key); - mctx->r = get_le32(key + 4); - return 0; -} - - -static struct crypto_alg michael_mic_alg = { - .cra_name = "michael_mic", - .cra_flags = CRYPTO_ALG_TYPE_DIGEST, - .cra_blocksize = 8, - .cra_ctxsize = sizeof(struct michael_mic_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(michael_mic_alg.cra_list), - .cra_u = { .digest = { - .dia_digestsize = 8, - .dia_init = michael_init, - .dia_update = michael_update, - .dia_final = michael_final, - .dia_setkey = michael_setkey } } -}; - - -static int __init michael_mic_init(void) -{ - return crypto_register_alg(&michael_mic_alg); -} - - -static void __exit michael_mic_exit(void) -{ - crypto_unregister_alg(&michael_mic_alg); -} - - -module_init(michael_mic_init); -module_exit(michael_mic_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Michael MIC"); -MODULE_AUTHOR("Jouni Malinen "); diff --git a/drivers/staging/rtl8192u/ieee80211/proc.c b/drivers/staging/rtl8192u/ieee80211/proc.c deleted file mode 100644 index c426dfdd9fdd..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/proc.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Scatterlist Cryptographic API. - * - * Procfs information. - * - * Copyright (c) 2002 James Morris - * - * 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 "rtl_crypto.h" -#include -#include -#include -#include "internal.h" - -extern struct list_head crypto_alg_list; -extern struct rw_semaphore crypto_alg_sem; - -static void *c_start(struct seq_file *m, loff_t *pos) -{ - struct list_head *v; - loff_t n = *pos; - - down_read(&crypto_alg_sem); - list_for_each(v, &crypto_alg_list) - if (!n--) - return list_entry(v, struct crypto_alg, cra_list); - return NULL; -} - -static void *c_next(struct seq_file *m, void *p, loff_t *pos) -{ - struct list_head *v = p; - - (*pos)++; - v = v->next; - return (v == &crypto_alg_list) ? - NULL : list_entry(v, struct crypto_alg, cra_list); -} - -static void c_stop(struct seq_file *m, void *p) -{ - up_read(&crypto_alg_sem); -} - -static int c_show(struct seq_file *m, void *p) -{ - struct crypto_alg *alg = (struct crypto_alg *)p; - - seq_printf(m, "name : %s\n", alg->cra_name); - seq_printf(m, "module : %s\n", - (alg->cra_module ? - alg->cra_module->name : - "kernel")); - - switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { - case CRYPTO_ALG_TYPE_CIPHER: - seq_printf(m, "type : cipher\n"); - seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); - seq_printf(m, "min keysize : %u\n", - alg->cra_cipher.cia_min_keysize); - seq_printf(m, "max keysize : %u\n", - alg->cra_cipher.cia_max_keysize); - break; - - case CRYPTO_ALG_TYPE_DIGEST: - seq_printf(m, "type : digest\n"); - seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); - seq_printf(m, "digestsize : %u\n", - alg->cra_digest.dia_digestsize); - break; - case CRYPTO_ALG_TYPE_COMPRESS: - seq_printf(m, "type : compression\n"); - break; - default: - seq_printf(m, "type : unknown\n"); - break; - } - - seq_putc(m, '\n'); - return 0; -} - -static struct seq_operations crypto_seq_ops = { - .start = c_start, - .next = c_next, - .stop = c_stop, - .show = c_show -}; - -static int crypto_info_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &crypto_seq_ops); -} - -static const struct file_operations proc_crypto_ops = { - .open = crypto_info_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release -}; - -void __init crypto_init_proc(void) -{ - proc_create("crypto", 0, NULL, &proc_crypto_ops); -} diff --git a/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h b/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h deleted file mode 100644 index c3c87108ee9e..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h +++ /dev/null @@ -1,398 +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); -#ifdef CONFIG_CRYPTO_HMAC - void *dit_hmac_block; -#endif -}; - -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); -} - -/* - * HMAC support. - */ -#ifdef CONFIG_CRYPTO_HMAC -void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen); -void crypto_hmac_update(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); -void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key, - unsigned int *keylen, u8 *out); -void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen, - struct scatterlist *sg, unsigned int nsg, u8 *out); -#endif /* CONFIG_CRYPTO_HMAC */ - -#endif /* _LINUX_CRYPTO_H */ diff --git a/drivers/staging/rtl8192u/ieee80211/scatterwalk.c b/drivers/staging/rtl8192u/ieee80211/scatterwalk.c deleted file mode 100644 index 8b73f6cefcf9..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/scatterwalk.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Cryptographic API. - * - * Cipher operations. - * - * Copyright (c) 2002 James Morris - * 2002 Adam J. Richter - * 2004 Jean-Luc Cooke - * - * 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 "internal.h" -#include "scatterwalk.h" - -void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, void *scratch) -{ - if (nbytes <= walk->len_this_page && - (((unsigned long)walk->data) & (PAGE_CACHE_SIZE - 1)) + nbytes <= - PAGE_CACHE_SIZE) - return walk->data; - else - return scratch; -} - -static void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out) -{ - if (out) - memcpy(sgdata, buf, nbytes); - else - memcpy(buf, sgdata, nbytes); -} - -void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg) -{ - unsigned int rest_of_page; - - walk->sg = sg; - - walk->page = sg->page; - walk->len_this_segment = sg->length; - - rest_of_page = PAGE_CACHE_SIZE - (sg->offset & (PAGE_CACHE_SIZE - 1)); - walk->len_this_page = min(sg->length, rest_of_page); - walk->offset = sg->offset; -} - -void scatterwalk_map(struct scatter_walk *walk) -{ - walk->data = kmap_atomic(walk->page) + walk->offset; -} - -static void scatterwalk_pagedone(struct scatter_walk *walk, int out, - unsigned int more) -{ - /* walk->data may be pointing the first byte of the next page; - however, we know we transferred at least one byte. So, - walk->data - 1 will be a virtual address in the mapped page. */ - - if (out) - flush_dcache_page(walk->page); - - if (more) { - walk->len_this_segment -= walk->len_this_page; - - if (walk->len_this_segment) { - walk->page++; - walk->len_this_page = min(walk->len_this_segment, - (unsigned)PAGE_CACHE_SIZE); - walk->offset = 0; - } - else - scatterwalk_start(walk, sg_next(walk->sg)); - } -} - -void scatterwalk_done(struct scatter_walk *walk, int out, int more) -{ - crypto_kunmap(walk->data, out); - if (walk->len_this_page == 0 || !more) - scatterwalk_pagedone(walk, out, more); -} - -/* - * Do not call this unless the total length of all of the fragments - * has been verified as multiple of the block size. - */ -int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, - size_t nbytes) -{ - if (buf != walk->data) { - while (nbytes > walk->len_this_page) { - memcpy_dir(buf, walk->data, walk->len_this_page, out); - buf += walk->len_this_page; - nbytes -= walk->len_this_page; - - kunmap_atomic(walk->data); - scatterwalk_pagedone(walk, out, 1); - scatterwalk_map(walk); - } - - memcpy_dir(buf, walk->data, nbytes, out); - } - - walk->offset += nbytes; - walk->len_this_page -= nbytes; - walk->len_this_segment -= nbytes; - return 0; -} diff --git a/drivers/staging/rtl8192u/ieee80211/scatterwalk.h b/drivers/staging/rtl8192u/ieee80211/scatterwalk.h deleted file mode 100644 index b16446519017..000000000000 --- a/drivers/staging/rtl8192u/ieee80211/scatterwalk.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Cryptographic API. - * - * Copyright (c) 2002 James Morris - * Copyright (c) 2002 Adam J. Richter - * Copyright (c) 2004 Jean-Luc Cooke - * - * 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 _CRYPTO_SCATTERWALK_H -#define _CRYPTO_SCATTERWALK_H -#include -#include - -struct scatter_walk { - struct scatterlist *sg; - struct page *page; - void *data; - unsigned int len_this_page; - unsigned int len_this_segment; - unsigned int offset; -}; - -/* Define sg_next is an inline routine now in case we want to change - scatterlist to a linked list later. */ -static inline struct scatterlist *sg_next(struct scatterlist *sg) -{ - return sg + 1; -} - -static inline int scatterwalk_samebuf(struct scatter_walk *walk_in, - struct scatter_walk *walk_out, - void *src_p, void *dst_p) -{ - return walk_in->page == walk_out->page && - walk_in->offset == walk_out->offset && - walk_in->data == src_p && walk_out->data == dst_p; -} - -void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, void *scratch); -void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg); -int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out); -void scatterwalk_map(struct scatter_walk *walk, int out); -void scatterwalk_done(struct scatter_walk *walk, int out, int more); - -#endif /* _CRYPTO_SCATTERWALK_H */ diff --git a/drivers/staging/rtl8192u/r819xU_HTGen.h b/drivers/staging/rtl8192u/r819xU_HTGen.h deleted file mode 100644 index 6a4678f7da5f..000000000000 --- a/drivers/staging/rtl8192u/r819xU_HTGen.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// IOT Action for different AP -// -typedef enum _HT_IOT_ACTION{ - HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001, - HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002, - HT_IOT_ACT_DECLARE_MCS13 = 0x00000004, - HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000008, - HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000010, - HT_IOT_ACT_CDD_FSYNC = 0x00000020, - HT_IOT_ACT_PURE_N_MODE = 0x00000040, -}HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; diff --git a/drivers/staging/rtl8192u/r819xU_HTType.h b/drivers/staging/rtl8192u/r819xU_HTType.h deleted file mode 100644 index 2cbb8e6584f8..000000000000 --- a/drivers/staging/rtl8192u/r819xU_HTType.h +++ /dev/null @@ -1,379 +0,0 @@ -#ifndef _R819XU_HTTYPE_H_ -#define _R819XU_HTTYPE_H_ - - -/*---------------------------------------------------------------------- - * The HT Capability element is present in beacons, association request, - * reassociation request and probe response frames - *----------------------------------------------------------------------*/ - -/* Operation mode value */ -#define HT_OPMODE_NO_PROTECT 0 -#define HT_OPMODE_OPTIONAL 1 -#define HT_OPMODE_40MHZ_PROTECT 2 -#define HT_OPMODE_MIXED 3 - -/* MIMO Power Save Settings */ -#define MIMO_PS_STATIC 0 -#define MIMO_PS_DYNAMIC 1 -#define MIMO_PS_NOLIMIT 3 - - -/* There should be 128 bits to cover all of the MCS rates. However, since - * 8190 does not support too much rates, one integer is quite enough. */ - -#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) - - -typedef 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, - /* Do not define MCS32 here although 8190 support MCS32 */ -} HT_MCS_RATE, *PHT_MCS_RATE; - -/* Represent Channel Width in HT Capabilities */ -typedef enum _HT_CHANNEL_WIDTH { - HT_CHANNEL_WIDTH_20 = 0, - HT_CHANNEL_WIDTH_20_40 = 1, -} HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH; - -/* Represent Extension Channel Offset in HT Capabilities - * This is available only in 40Mhz mode. */ -typedef enum _HT_EXTCHNL_OFFSET { - HT_EXTCHNL_OFFSET_NO_EXT = 0, - HT_EXTCHNL_OFFSET_UPPER = 1, - HT_EXTCHNL_OFFSET_NO_DEF = 2, - HT_EXTCHNL_OFFSET_LOWER = 3, -} HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET; - -typedef enum _CHNLOP { - CHNLOP_NONE = 0, /* No Action now */ - CHNLOP_SCAN = 1, /* Scan in progress */ - CHNLOP_SWBW = 2, /* Bandwidth switching in progress */ - CHNLOP_SWCHNL = 3, /* Software Channel switching in progress */ -} CHNLOP, *PCHNLOP; - -/* Determine if the Channel Operation is in progress */ -#define CHHLOP_IN_PROGRESS(_pHTInfo) \ - (((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE) - - -typedef 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, -} HT_ACTION, *PHT_ACTION; - - -/* Define sub-carrier mode for 40MHZ. */ -typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier { - SC_MODE_DUPLICATE = 0, - SC_MODE_LOWER = 1, - SC_MODE_UPPER = 2, - SC_MODE_FULL40MHZ = 3, -} HT_BW40_SC_E; - -typedef struct _HT_CAPABILITY_ELE { - - /* HT capability info */ - u8 AdvCoding:1; - u8 ChlWidth:1; - u8 MimoPwrSave:2; - u8 GreenField:1; - u8 ShortGI20Mhz:1; - u8 ShortGI40Mhz:1; - u8 TxSTBC:1; - u8 RxSTBC:2; - u8 DelayBA:1; - u8 MaxAMSDUSize:1; - u8 DssCCk:1; - u8 PSMP:1; - u8 Rsvd1:1; - u8 LSigTxopProtect:1; - - /* MAC HT parameters info */ - u8 MaxRxAMPDUFactor:2; - u8 MPDUDensity:3; - u8 Rsvd2:3; - - /* Supported MCS set */ - u8 MCS[16]; - - - /* Extended HT Capability Info */ - u16 ExtHTCapInfo; - - /* TXBF Capabilities */ - u8 TxBFCap[4]; - - /* Antenna Selection Capabilities */ - u8 ASCap; - -} __packed HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE; - -/*------------------------------------------------------------ - * The HT Information element is present in beacons - * Only AP is required to include this element - *------------------------------------------------------------*/ - -typedef struct _HT_INFORMATION_ELE { - u8 ControlChl; - - u8 ExtChlOffset:2; - u8 RecommemdedTxWidth:1; - u8 RIFS:1; - u8 PSMPAccessOnly:1; - u8 SrvIntGranularity:3; - - u8 OptMode:2; - u8 NonGFDevPresent:1; - u8 Revd1:5; - u8 Revd2:8; - - u8 Rsvd3:6; - u8 DualBeacon:1; - u8 DualCTSProtect:1; - - u8 SecondaryBeacon:1; - u8 LSigTxopProtectFull:1; - u8 PcoActive:1; - u8 PcoPhase:1; - u8 Rsvd4:4; - - u8 BasicMSC[16]; -} __packed HT_INFORMATION_ELE, *PHT_INFORMATION_ELE; - -/* MIMO Power Save control field. - * This is appear in MIMO Power Save Action Frame */ -typedef struct _MIMOPS_CTRL { - u8 MimoPsEnable:1; - u8 MimoPsMode:1; - u8 Reserved:6; -} MIMOPS_CTRL, *PMIMOPS_CTRL; - -typedef enum _HT_SPEC_VER { - HT_SPEC_VER_IEEE = 0, - HT_SPEC_VER_EWC = 1, -} HT_SPEC_VER, *PHT_SPEC_VER; - -typedef enum _HT_AGGRE_MODE_E { - HT_AGG_AUTO = 0, - HT_AGG_FORCE_ENABLE = 1, - HT_AGG_FORCE_DISABLE = 2, -} HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E; - -/*---------------------------------------------------------------------------- - * The Data structure is used to keep HT related variables when card is - * configured as non-AP STA mode. - * **Note** Current_xxx should be set to default value in HTInitializeHTInfo() - *----------------------------------------------------------------------------*/ - -typedef struct _RT_HIGH_THROUGHPUT { - u8 bEnableHT; - u8 bCurrentHTSupport; - /* Tx 40MHz channel capability */ - u8 bRegBW40MHz; - u8 bCurBW40MHz; - /* Tx Short GI for 40Mhz */ - u8 bRegShortGI40MHz; - u8 bCurShortGI40MHz; - /* Tx Short GI for 20MHz */ - u8 bRegShortGI20MHz; - u8 bCurShortGI20MHz; - /* Tx CCK rate capability */ - u8 bRegSuppCCK; - u8 bCurSuppCCK; - - /* 802.11n spec version for "peer" */ - HT_SPEC_VER ePeerHTSpecVer; - - - /* HT related information for "Self" */ - /* This is HT cap element sent to peer STA, which also indicate - * HT Rx capabilities. */ - HT_CAPABILITY_ELE SelfHTCap; - HT_INFORMATION_ELE SelfHTInfo; - - /* HT related information for "Peer" */ - u8 PeerHTCapBuf[32]; - u8 PeerHTInfoBuf[32]; - - - /* A-MSDU related */ - /* This indicates Tx A-MSDU capability */ - u8 bAMSDU_Support; - u16 nAMSDU_MaxSize; - u8 bCurrent_AMSDU_Support; - u16 nCurrent_AMSDU_MaxSize; - - - /* A-MPDU related */ - /* This indicate Tx A-MPDU capability */ - u8 bAMPDUEnable; - u8 bCurrentAMPDUEnable; - u8 AMPDU_Factor; - u8 CurrentAMPDUFactor; - u8 MPDU_Density; - u8 CurrentMPDUDensity; - - /* Forced A-MPDU enable */ - HT_AGGRE_MODE_E ForcedAMPDUMode; - u8 ForcedAMPDUFactor; - u8 ForcedMPDUDensity; - - /* Forced A-MSDU enable */ - HT_AGGRE_MODE_E ForcedAMSDUMode; - u16 ForcedAMSDUMaxSize; - - u8 bForcedShortGI; - - u8 CurrentOpMode; - - /* MIMO PS related */ - u8 SelfMimoPs; - u8 PeerMimoPs; - - /* 40MHz Channel Offset settings. */ - HT_EXTCHNL_OFFSET CurSTAExtChnlOffset; - u8 bCurTxBW40MHz; /* If we use 40 MHz to Tx */ - u8 PeerBandwidth; - - /* For Bandwidth Switching */ - u8 bSwBwInProgress; - CHNLOP ChnlOp; /* sw switching channel in progress. */ - u8 SwBwStep; - struct timer_list SwBwTimer; - - /* For Realtek proprietary A-MPDU factor for aggregation */ - u8 bRegRT2RTAggregation; - u8 bCurrentRT2RTAggregation; - u8 bCurrentRT2RTLongSlotTime; - u8 szRT2RTAggBuffer[10]; - - /* Rx Reorder control */ - u8 bRegRxReorderEnable; - u8 bCurRxReorderEnable; - u8 RxReorderWinSize; - u8 RxReorderPendingTime; - u16 RxReorderDropCounter; - -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - u8 UsbTxAggrNum; -#endif -#ifdef USB_RX_AGGREGATION_SUPPORT - u8 UsbRxFwAggrEn; - u8 UsbRxFwAggrPageNum; - u8 UsbRxFwAggrPacketNum; - u8 UsbRxFwAggrTimeout; -#endif - - /* Add for Broadcom(Linksys) IOT. */ - u8 bIsPeerBcm; - - /* For IOT issue. */ - u32 IOTAction; -} RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT; - - -/*---------------------------------------------------------------------- - * The Data structure is used to keep HT related variable for "each Sta" - * when card is configured as "AP mode" - *----------------------------------------------------------------------*/ - -typedef struct _RT_HTINFO_STA_ENTRY { - u8 bEnableHT; - - u8 bSupportCck; - - u16 AMSDU_MaxSize; - - u8 AMPDU_Factor; - u8 MPDU_Density; - - u8 HTHighestOperaRate; - - u8 bBw40MHz; - - u8 MimoPs; - - u8 McsRateSet[16]; - - -} RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY; - - - - - -/*--------------------------------------------------------------------- - * The Data structure is used to keep HT related variable for "each AP" - * when card is configured as "STA mode" - *---------------------------------------------------------------------*/ - -typedef struct _BSS_HT { - - u8 bdSupportHT; - - /* HT related elements */ - u8 bdHTCapBuf[32]; - u16 bdHTCapLen; - u8 bdHTInfoBuf[32]; - u16 bdHTInfoLen; - - HT_SPEC_VER bdHTSpecVer; - - u8 bdRT2RTAggregation; - u8 bdRT2RTLongSlotTime; -} BSS_HT, *PBSS_HT; - -typedef struct _MIMO_RSSI { - u32 EnableAntenna; - u32 AntennaA; - u32 AntennaB; - u32 AntennaC; - u32 AntennaD; - u32 Average; -} MIMO_RSSI, *PMIMO_RSSI; - -typedef struct _MIMO_EVM { - u32 EVM1; - u32 EVM2; -} MIMO_EVM, *PMIMO_EVM; - -typedef struct _FALSE_ALARM_STATISTICS { - u32 Cnt_Parity_Fail; - u32 Cnt_Rate_Illegal; - u32 Cnt_Crc8_fail; - u32 Cnt_all; -} FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS; - - - -#endif From 2ec1cb760582f8e666fb493ed1ccec7d5cc3d8c6 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Wed, 5 Feb 2014 11:49:36 +0900 Subject: [PATCH 0067/1375] Staging: rtl8812ae: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/base.c b/drivers/staging/rtl8821ae/base.c index 30b3d3982703..da04f034e114 100644 --- a/drivers/staging/rtl8821ae/base.c +++ b/drivers/staging/rtl8821ae/base.c @@ -1715,7 +1715,7 @@ static ssize_t rtl_store_debug_level(struct device *d, unsigned long val; int ret; - ret = strict_strtoul(buf, 0, &val); + ret = kstrtoul(buf, 0, &val); if (ret) { printk(KERN_DEBUG "%s is not in hex or decimal form.\n", buf); } else { From ba92b22515e1230661cab7ba2a025910c0636c15 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 6 Feb 2014 10:12:03 -0200 Subject: [PATCH 0068/1375] imx-drm: imx-hdmi: Remove parentheses from returns Fix the following checkpatch warnings: ERROR: return is not a function, parentheses are not required #462: FILE: drivers/staging/imx-drm/imx-hdmi.c:462: + return (hdmi->hdmi_data.enc_in_format != ERROR: return is not a function, parentheses are not required #468: FILE: drivers/staging/imx-drm/imx-hdmi.c:468: + return ((hdmi->hdmi_data.enc_out_format == YCBCR422_8BITS) && ERROR: return is not a function, parentheses are not required #475: FILE: drivers/staging/imx-drm/imx-hdmi.c:475: + return ((hdmi->hdmi_data.enc_in_format == YCBCR422_8BITS) && While at it, broke the return code from is_color_space_decimation() and is_color_space_interpolation() for better readability Signed-off-by: Fabio Estevam Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-hdmi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index f3a1f5e2e492..01a54ee274bb 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -463,22 +463,27 @@ static void hdmi_video_sample(struct imx_hdmi *hdmi) static int is_color_space_conversion(struct imx_hdmi *hdmi) { - return (hdmi->hdmi_data.enc_in_format != - hdmi->hdmi_data.enc_out_format); + return hdmi->hdmi_data.enc_in_format != hdmi->hdmi_data.enc_out_format; } static int is_color_space_decimation(struct imx_hdmi *hdmi) { - return ((hdmi->hdmi_data.enc_out_format == YCBCR422_8BITS) && - (hdmi->hdmi_data.enc_in_format == RGB || - hdmi->hdmi_data.enc_in_format == YCBCR444)); + if (hdmi->hdmi_data.enc_out_format != YCBCR422_8BITS) + return 0; + if (hdmi->hdmi_data.enc_in_format == RGB || + hdmi->hdmi_data.enc_in_format == YCBCR444) + return 1; + return 0; } static int is_color_space_interpolation(struct imx_hdmi *hdmi) { - return ((hdmi->hdmi_data.enc_in_format == YCBCR422_8BITS) && - (hdmi->hdmi_data.enc_out_format == RGB || - hdmi->hdmi_data.enc_out_format == YCBCR444)); + if (hdmi->hdmi_data.enc_in_format != YCBCR422_8BITS) + return 0; + if (hdmi->hdmi_data.enc_out_format == RGB || + hdmi->hdmi_data.enc_out_format == YCBCR444) + return 1; + return 0; } static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi) From a863a15bf24ae025ec8c3d6b23600fd6cdd94edf Mon Sep 17 00:00:00 2001 From: "Zhao, Gang" Date: Thu, 6 Feb 2014 00:10:34 +0800 Subject: [PATCH 0069/1375] staging: et131x: stop read when hit max delay in et131x_phy_mii_read stop read and return error when hit max delay time. Signed-off-by: Zhao, Gang Acked-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index e516bb69f3b4..cf970495efc9 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -1388,6 +1388,7 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, mii_indicator); status = -EIO; + goto out; } /* If we hit here we were able to read the register and we need to @@ -1395,6 +1396,7 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, */ *value = readl(&mac->mii_mgmt_stat) & ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK; +out: /* Stop the read operation */ writel(0, &mac->mii_mgmt_cmd); From 0b15862d46fd630e2550bd215307235e62fb756b Mon Sep 17 00:00:00 2001 From: "Zhao, Gang" Date: Thu, 6 Feb 2014 00:10:35 +0800 Subject: [PATCH 0070/1375] staging: et131x: remove spinlock adapter->lock adapter->lock is only used in et131x_multicast(), which is eventually called by network stack function __dev_set_rx_mode(). __dev_set_rx_mode() is always called by (net_device *)dev->addr_list_lock hold, to protect from concurrent access. So adapter->lock is redundant. Signed-off-by: Zhao, Gang Acked-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index cf970495efc9..641350039242 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -485,8 +485,6 @@ struct et131x_adapter { u8 eeprom_data[2]; /* Spinlocks */ - spinlock_t lock; - spinlock_t tcb_send_qlock; spinlock_t tcb_ready_qlock; spinlock_t send_hw_lock; @@ -3762,7 +3760,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, adapter->netdev = netdev; /* Initialize spinlocks here */ - spin_lock_init(&adapter->lock); spin_lock_init(&adapter->tcb_send_qlock); spin_lock_init(&adapter->tcb_ready_qlock); spin_lock_init(&adapter->send_hw_lock); @@ -4294,12 +4291,9 @@ static void et131x_multicast(struct net_device *netdev) { struct et131x_adapter *adapter = netdev_priv(netdev); int packet_filter; - unsigned long flags; struct netdev_hw_addr *ha; int i; - spin_lock_irqsave(&adapter->lock, flags); - /* Before we modify the platform-independent filter flags, store them * locally. This allows us to determine if anything's changed and if * we even need to bother the hardware @@ -4351,8 +4345,6 @@ static void et131x_multicast(struct net_device *netdev) */ if (packet_filter != adapter->packet_filter) et131x_set_packet_filter(adapter); - - spin_unlock_irqrestore(&adapter->lock, flags); } /* et131x_tx - The handler to tx a packet on the device */ From ce8386da7488c998969288355111996c2c23c892 Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Tue, 4 Feb 2014 17:36:39 +0900 Subject: [PATCH 0071/1375] staging: cxt1e1: remove unnecessary function, VMETRO_TRACE VMETRO_TRACE isn't called from anywhere. So delete it. Signed-off-by: SeongJae Park Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/functions.c | 9 --------- drivers/staging/cxt1e1/pmcc4.h | 1 - 2 files changed, 10 deletions(-) diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index 95218e283966..f5ce8529b4ae 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -262,15 +262,6 @@ void sd_recv_consume(void *token, size_t len, void *user) #include "comet.h" extern ci_t *CI; /* dummy pointer to board ZERO's data */ -void -VMETRO_TRACE (void *x) -{ - u_int32_t y = (u_int32_t) x; - - pci_write_32 ((u_int32_t *) &CI->cpldbase->leds, y); -} - - void VMETRO_TRIGGER (ci_t *ci, int x) { diff --git a/drivers/staging/cxt1e1/pmcc4.h b/drivers/staging/cxt1e1/pmcc4.h index 003eb8690190..b4b5e5ad791b 100644 --- a/drivers/staging/cxt1e1/pmcc4.h +++ b/drivers/staging/cxt1e1/pmcc4.h @@ -96,7 +96,6 @@ void sbeid_set_bdtype (ci_t *ci); void sbeid_set_hdwbid (ci_t *ci); u_int32_t sbeCrc (u_int8_t *, u_int32_t, u_int32_t, u_int32_t *); -void VMETRO_TRACE (void *); /* put data into 8 LEDs */ void VMETRO_TRIGGER (ci_t *, int); /* Note: int = 0(default) * thru 15 */ From 9dd7210250505b7b1315f8c7e24336d82f4d866b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:36 -0600 Subject: [PATCH 0072/1375] staging: r8188eu: Remove ODM_Read1Byte This is essentially a synonym for rtw_read8. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c | 6 +++--- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ------ drivers/staging/rtl8188eu/include/odm_interface.h | 2 -- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index 15e8e3f62198..6581a27cc406 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -839,7 +839,7 @@ static void _PHY_SaveMACRegisters( struct odm_dm_struct *dm_odm = &pHalData->odmpriv; ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n")); for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { - MACBackup[i] = ODM_Read1Byte(dm_odm, MACReg[i]); + MACBackup[i] = rtw_read8(adapt, MACReg[i]); } MACBackup[i] = ODM_Read4Byte(dm_odm, MACReg[i]); } @@ -1227,7 +1227,7 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) struct odm_dm_struct *dm_odm = &pHalData->odmpriv; /* Check continuous TX and Packet TX */ - tmpreg = ODM_Read1Byte(dm_odm, 0xd03); + tmpreg = rtw_read8(adapt, 0xd03); if ((tmpreg&0x70) != 0) /* Deal with contisuous TX case */ ODM_Write1Byte(dm_odm, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ @@ -1473,7 +1473,7 @@ static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2 if (!adapt->hw_init_completed) { u8 u1btmp; - u1btmp = ODM_Read1Byte(dm_odm, REG_LEDCFG2) | BIT7; + u1btmp = rtw_read8(adapt, REG_LEDCFG2) | BIT7; ODM_Write1Byte(dm_odm, REG_LEDCFG2, u1btmp); PHY_SetBBReg(adapt, rFPGA0_XAB_RFParameter, BIT13, 0x01); } diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 3cd68212afd1..5b290670c48e 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -21,12 +21,6 @@ #include "odm_precomp.h" /* ODM IO Relative API. */ -u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return rtw_read8(Adapter, RegAddr); -} - u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) { struct adapter *Adapter = pDM_Odm->Adapter; diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index a50eae3ec68e..ba061010e2dd 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -77,8 +77,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ -u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); - u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); From e482338e7d95533df5cb7fdcee3acbe6190e11f8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:37 -0600 Subject: [PATCH 0073/1375] staging: r8188eu: Remove ODM_Read2Byte This routine is never used. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ------ drivers/staging/rtl8188eu/include/odm_interface.h | 2 -- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 5b290670c48e..f8d1692ce29e 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -21,12 +21,6 @@ #include "odm_precomp.h" /* ODM IO Relative API. */ -u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return rtw_read16(Adapter, RegAddr); -} - u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) { struct adapter *Adapter = pDM_Odm->Adapter; diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index ba061010e2dd..84c6449558c2 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -77,8 +77,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ -u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); - u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data); From 2325182f1ea478249ad2067f58177cc387c813ff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:38 -0600 Subject: [PATCH 0074/1375] staging: r8188eu: Remove ODM_Read4Byte This routine is essentially a duplicate of rtw_read32. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c | 9 +++++---- drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c | 2 +- drivers/staging/rtl8188eu/hal/odm.c | 8 ++++---- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ------ drivers/staging/rtl8188eu/include/odm_interface.h | 2 -- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c index 3df33bc7197a..908a2c094cb3 100644 --- a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c @@ -331,6 +331,7 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) { /* Wilson 2011/10/26 */ + struct adapter *adapt = dm_odm->Adapter; u32 MaskFromReg; s8 i; @@ -357,19 +358,19 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0000000d; break; case 12: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR0); + MaskFromReg = rtw_read32(adapt, REG_ARFR0); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; case 13: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR1); + MaskFromReg = rtw_read32(adapt, REG_ARFR1); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; case 14: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR2); + MaskFromReg = rtw_read32(adapt, REG_ARFR2); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; case 15: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR3); + MaskFromReg = rtw_read32(adapt, REG_ARFR3); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; default: diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index 6581a27cc406..9f907f8fc5d8 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -841,7 +841,7 @@ static void _PHY_SaveMACRegisters( for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { MACBackup[i] = rtw_read8(adapt, MACReg[i]); } - MACBackup[i] = ODM_Read4Byte(dm_odm, MACReg[i]); + MACBackup[i] = rtw_read32(adapt, MACReg[i]); } static void reload_adda_reg(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 3555ffaa4e06..5d41ef92e1d9 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1433,10 +1433,10 @@ void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; Adapter->recvpriv.bIsAnyNonBEPkts = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VO_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VI_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BK_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", rtw_read32(Adapter, ODM_EDCA_VO_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", rtw_read32(Adapter, ODM_EDCA_VI_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", rtw_read32(Adapter, ODM_EDCA_BE_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", rtw_read32(Adapter, ODM_EDCA_BK_PARAM))); } /* ODM_InitEdcaTurbo */ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index f8d1692ce29e..ae4f30ceb9f7 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -21,12 +21,6 @@ #include "odm_precomp.h" /* ODM IO Relative API. */ -u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return rtw_read32(Adapter, RegAddr); -} - void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data) { struct adapter *Adapter = pDM_Odm->Adapter; diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 84c6449558c2..adcdc3966c1c 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -77,8 +77,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ -u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); - void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data); void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data); From 6348c2325a8bdf28f831a478c34f03c855bbdf5c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:39 -0600 Subject: [PATCH 0075/1375] staging: r8188eu: Remove ODM_Write1Byte This routine is the equivalent of rtl_write6. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/HalPhyRf_8188e.c | 23 ++++++++----------- drivers/staging/rtl8188eu/hal/odm.c | 3 ++- .../rtl8188eu/hal/odm_RegConfig8188E.c | 4 +++- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ----- .../staging/rtl8188eu/include/odm_interface.h | 2 -- 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index 9f907f8fc5d8..bb80b8a94b6a 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -868,7 +868,7 @@ _PHY_ReloadMACRegisters( ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload MAC parameters !\n")); for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { - ODM_Write1Byte(dm_odm, MACReg[i], (u8)MACBackup[i]); + rtw_write8(adapt, MACReg[i], (u8)MACBackup[i]); } ODM_Write4Byte(dm_odm, MACReg[i], MACBackup[i]); } @@ -912,12 +912,12 @@ _PHY_MACSettingCalibration( ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n")); - ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); + rtw_write8(adapt, MACReg[i], 0x3F); for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); + rtw_write8(adapt, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); } - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); + rtw_write8(adapt, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); } void @@ -1223,16 +1223,14 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) { u8 tmpreg; u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; /* Check continuous TX and Packet TX */ tmpreg = rtw_read8(adapt, 0xd03); if ((tmpreg&0x70) != 0) /* Deal with contisuous TX case */ - ODM_Write1Byte(dm_odm, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ + rtw_write8(adapt, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ else /* Deal with Packet TX case */ - ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0xFF); /* block all queues */ + rtw_write8(adapt, REG_TXPAUSE, 0xFF); /* block all queues */ if ((tmpreg&0x70) != 0) { /* 1. Read original RF mode */ @@ -1264,7 +1262,7 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) if ((tmpreg&0x70) != 0) { /* Deal with continuous TX case */ /* Path-A */ - ODM_Write1Byte(dm_odm, 0xd03, tmpreg); + rtw_write8(adapt, 0xd03, tmpreg); PHY_SetRFReg(adapt, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); /* Path-B */ @@ -1272,7 +1270,7 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) PHY_SetRFReg(adapt, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); } else { /* Deal with Packet TX case */ - ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0x00); + rtw_write8(adapt, REG_TXPAUSE, 0x00); } } @@ -1468,13 +1466,10 @@ void PHY_LCCalibrate_8188E(struct adapter *adapt) static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2t) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - if (!adapt->hw_init_completed) { u8 u1btmp; u1btmp = rtw_read8(adapt, REG_LEDCFG2) | BIT7; - ODM_Write1Byte(dm_odm, REG_LEDCFG2, u1btmp); + rtw_write8(adapt, REG_LEDCFG2, u1btmp); PHY_SetBBReg(adapt, rFPGA0_XAB_RFParameter, BIT13, 0x01); } diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 5d41ef92e1d9..fc05e482be77 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -887,9 +887,10 @@ void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) { struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + struct adapter *adapt = pDM_Odm->Adapter; if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ - ODM_Write1Byte(pDM_Odm, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); + rtw_write8(adapt, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; } diff --git a/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c index 6193d9fafb98..a9886122b459 100644 --- a/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c +++ b/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c @@ -66,7 +66,9 @@ void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) { - ODM_Write1Byte(pDM_Odm, Addr, Data); + struct adapter *adapt = pDM_Odm->Adapter; + + rtw_write8(adapt, Addr, Data); ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", Addr, Data)); } diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index ae4f30ceb9f7..76c54dc1aa85 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -21,12 +21,6 @@ #include "odm_precomp.h" /* ODM IO Relative API. */ -void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - rtw_write8(Adapter, RegAddr, Data); -} - void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data) { struct adapter *Adapter = pDM_Odm->Adapter; diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index adcdc3966c1c..a11dec1abc86 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -77,8 +77,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ -void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data); - void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data); void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data); From 4107a998ee2a4b3df5cc9469a7c7960b5a6c4a75 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:40 -0600 Subject: [PATCH 0076/1375] staging: r8188eu: Remove ODM_Write2Byte This routine is the equivalent of rtw_write16. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c | 4 +++- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ------ drivers/staging/rtl8188eu/include/odm_interface.h | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c index 908a2c094cb3..dea220b507ad 100644 --- a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c @@ -668,7 +668,9 @@ void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime) { - ODM_Write2Byte(dm_odm, REG_TX_RPT_TIME, minRptTime); + struct adapter *adapt = dm_odm->Adapter; + + rtw_write16(adapt, REG_TX_RPT_TIME, minRptTime); } void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 TxRPT_Len, u32 macid_entry0, u32 macid_entry1) diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 76c54dc1aa85..202790cda71c 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -21,12 +21,6 @@ #include "odm_precomp.h" /* ODM IO Relative API. */ -void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - rtw_write16(Adapter, RegAddr, Data); -} - void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data) { struct adapter *Adapter = pDM_Odm->Adapter; diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index a11dec1abc86..f45f172d2309 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -77,8 +77,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ -void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data); - void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data); /* Memory Relative Function. */ From 7d901c65feae680bae52874d109c0cd259a27cc8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:41 -0600 Subject: [PATCH 0077/1375] staging: r8188eu: Remove ODM_Write4Byte This routine is the equivalent of rtw_write32. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c | 2 +- drivers/staging/rtl8188eu/hal/odm_interface.c | 7 ------- drivers/staging/rtl8188eu/include/odm_interface.h | 2 -- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index bb80b8a94b6a..6af70ce93ac8 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -870,7 +870,7 @@ _PHY_ReloadMACRegisters( for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { rtw_write8(adapt, MACReg[i], (u8)MACBackup[i]); } - ODM_Write4Byte(dm_odm, MACReg[i], MACBackup[i]); + rtw_write32(adapt, MACReg[i], MACBackup[i]); } void diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 202790cda71c..b84b111950e4 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -19,13 +19,6 @@ ******************************************************************************/ #include "odm_precomp.h" -/* ODM IO Relative API. */ - -void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - rtw_write32(Adapter, RegAddr, Data); -} /* ODM Memory relative API. */ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index f45f172d2309..9284eb837708 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -77,8 +77,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ -void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data); - /* Memory Relative Function. */ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length); void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length); From 2397c6e0927675d983b34a03401affdb64818d07 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:42 -0600 Subject: [PATCH 0078/1375] staging: r8188eu: Remove wrappers around vmalloc and vzalloc Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_mp.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8188eu/core/rtw_xmit.c | 8 ++++---- drivers/staging/rtl8188eu/hal/odm_interface.c | 2 +- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 +- .../staging/rtl8188eu/include/osdep_service.h | 4 ---- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- .../staging/rtl8188eu/os_dep/osdep_service.c | 18 +----------------- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +- 11 files changed, 14 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index c7382303088f..c85fcfef8ee1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -45,7 +45,7 @@ int _rtw_init_mlme_priv (struct adapter *padapter) _func_enter_; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ pmlmepriv->nic_hdl = (u8 *)padapter; @@ -62,7 +62,7 @@ _func_enter_; _rtw_memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); + pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); if (pbuf == NULL) { res = _FAIL; diff --git a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c index 6451efdfb132..a88c5f141f55 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mp.c +++ b/drivers/staging/rtl8188eu/core/rtw_mp.c @@ -956,7 +956,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmit_extbuf == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index c9c180649c12..b2e00f9e9f97 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -77,7 +77,7 @@ _func_enter_; rtw_os_recv_resource_init(precvpriv, padapter); - precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); if (precvpriv->pallocated_frame_buf == NULL) { res = _FAIL; diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 02e1e1f8b3ea..21b205f710d5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -79,7 +79,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) _func_enter_; - pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4); + pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4); if (!pstapriv->pallocated_stainfo_buf) return _FAIL; diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 24182fbc6a71..e98c03849f6f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -65,7 +65,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) _func_enter_; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ spin_lock_init(&pxmitpriv->lock); sema_init(&pxmitpriv->xmit_sema, 0); @@ -91,7 +91,7 @@ _func_enter_; Please also apply free_txobj to link_up all the xmit_frames... */ - pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); if (pxmitpriv->pallocated_frame_buf == NULL) { pxmitpriv->pxmit_frame_buf = NULL; @@ -129,7 +129,7 @@ _func_enter_; _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); - pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmitbuf == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); @@ -171,7 +171,7 @@ _func_enter_; /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmit_extbuf == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index b84b111950e4..5ba95ab8292c 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -23,7 +23,7 @@ /* ODM Memory relative API. */ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) { - *pPtr = rtw_zvmalloc(length); + *pPtr = vzalloc(length); } /* length could be ignored, used to detect memory leakage. */ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 5921db86547f..d364abce11ea 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -365,7 +365,7 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) u32 fifo_data, reg_140; u32 addr, rstatus, loop = 0; u16 data_cnts = (data_len/8)+1; - u8 *pbuf = rtw_zvmalloc(data_len+10); + u8 *pbuf = vzalloc(data_len+10); DBG_88E("###### %s ######\n", __func__); rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 7956f0cdb96b..0d34c36d964a 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -230,14 +230,10 @@ extern unsigned char WPA_TKIP_CIPHER[4]; extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) -u8 *_rtw_vmalloc(u32 sz); -u8 *_rtw_zvmalloc(u32 sz); void _rtw_vmfree(u8 *pbuf, u32 sz); u8 *_rtw_zmalloc(u32 sz); u8 *_rtw_malloc(u32 sz); void _rtw_mfree(u8 *pbuf, u32 sz); -#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) -#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) #define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) #define rtw_malloc(sz) _rtw_malloc((sz)) #define rtw_zmalloc(sz) _rtw_zmalloc((sz)) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index dec992569476..a76878f094a8 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -5650,7 +5650,7 @@ static int rtw_wx_set_priv(struct net_device *dev, return -EFAULT; len = dwrq->length; - ext = rtw_vmalloc(len); + ext = vmalloc(len); if (!ext) return -ENOMEM; diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 8c3b077448af..02f5e0c90f9a 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -55,22 +55,6 @@ u32 rtw_atoi(u8 *s) return num; } -inline u8 *_rtw_vmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = vmalloc(sz); - return pbuf; -} - -inline u8 *_rtw_zvmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = _rtw_vmalloc(sz); - if (pbuf != NULL) - memset(pbuf, 0, sz); - return pbuf; -} - inline void _rtw_vmfree(u8 *pbuf, u32 sz) { vfree(pbuf); @@ -252,7 +236,7 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv) pnpi = netdev_priv(pnetdev); - pnpi->priv = rtw_zvmalloc(sizeof_priv); + pnpi->priv = vzalloc(sizeof_priv); if (!pnpi->priv) { free_netdev(pnetdev); pnetdev = NULL; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 0a341d6ec51f..e5539dd63719 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -646,7 +646,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, struct net_device *pnetdev = NULL; int status = _FAIL; - padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter)); + padapter = (struct adapter *)vzalloc(sizeof(*padapter)); if (padapter == NULL) goto exit; padapter->dvobj = dvobj; From 03bd6aea7ba610a1a19f840c373624b8b0adde0d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:43 -0600 Subject: [PATCH 0079/1375] staging: r8188eu: Remove wrappers around vfree Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 5 ++--- drivers/staging/rtl8188eu/core/rtw_mp.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8188eu/core/rtw_xmit.c | 6 +++--- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ------ drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/rtl8188eu/include/odm_interface.h | 1 - drivers/staging/rtl8188eu/include/osdep_service.h | 2 -- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++-- drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 +------ drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +- 12 files changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index c85fcfef8ee1..2037be0acab8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -129,9 +129,8 @@ _func_enter_; rtw_free_mlme_priv_ie_data(pmlmepriv); if (pmlmepriv) { - if (pmlmepriv->free_bss_buf) { - rtw_vmfree(pmlmepriv->free_bss_buf, MAX_BSS_CNT * sizeof(struct wlan_network)); - } + if (pmlmepriv->free_bss_buf) + vfree(pmlmepriv->free_bss_buf); } _func_exit_; } diff --git a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c index a88c5f141f55..9e97b5758368 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mp.c +++ b/drivers/staging/rtl8188eu/core/rtw_mp.c @@ -943,7 +943,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) } if (pxmitpriv->pallocated_xmit_extbuf) - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmit_extbuf); if (padapter->registrypriv.mp_mode == 0) { max_xmit_extbuf_size = 20000; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index b2e00f9e9f97..8490d510f31e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -129,7 +129,7 @@ _func_enter_; rtw_os_recv_resource_free(precvpriv); if (precvpriv->pallocated_frame_buf) { - rtw_vmfree(precvpriv->pallocated_frame_buf, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + vfree(precvpriv->pallocated_frame_buf); } rtw_hal_free_recv_priv(padapter); diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 21b205f710d5..6df96699ca43 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -208,7 +208,7 @@ _func_enter_; rtw_mfree_sta_priv_lock(pstapriv); if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); + vfree(pstapriv->pallocated_stainfo_buf); } _func_exit_; diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index e98c03849f6f..aa77270cd8cf 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -259,10 +259,10 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) } if (pxmitpriv->pallocated_frame_buf) - rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + vfree(pxmitpriv->pallocated_frame_buf); if (pxmitpriv->pallocated_xmitbuf) - rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmitbuf); /* free xmit extension buff */ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; @@ -272,7 +272,7 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) } if (pxmitpriv->pallocated_xmit_extbuf) { - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmit_extbuf); } rtw_free_hwxmits(padapter); diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 5ba95ab8292c..568c73476f8c 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -26,12 +26,6 @@ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) *pPtr = vzalloc(length); } -/* length could be ignored, used to detect memory leakage. */ -void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length) -{ - rtw_vmfree(pPtr, length); -} - s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) { return _rtw_memcmp(pBuf1, pBuf2, length); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index d364abce11ea..f29c0038c612 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -387,7 +387,7 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) } while (!rstatus && (loop++ < 10)); } rtw_IOL_cmd_buf_dump(Adapter, data_len, pbuf); - rtw_vmfree(pbuf, data_len+10); + vfree(pbuf); } DBG_88E("###### %s ######\n", __func__); } diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 9284eb837708..eb96d7a6d5ad 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -79,7 +79,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* Memory Relative Function. */ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length); -void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length); s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length); diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 0d34c36d964a..495420ebd9ed 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -230,11 +230,9 @@ extern unsigned char WPA_TKIP_CIPHER[4]; extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) -void _rtw_vmfree(u8 *pbuf, u32 sz); u8 *_rtw_zmalloc(u32 sz); u8 *_rtw_malloc(u32 sz); void _rtw_mfree(u8 *pbuf, u32 sz); -#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) #define rtw_malloc(sz) _rtw_malloc((sz)) #define rtw_zmalloc(sz) _rtw_zmalloc((sz)) #define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index a76878f094a8..961bfda2d9eb 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -5655,7 +5655,7 @@ static int rtw_wx_set_priv(struct net_device *dev, return -ENOMEM; if (copy_from_user(ext, dwrq->pointer, len)) { - rtw_vmfree(ext, len); + vfree(ext); return -EFAULT; } @@ -5695,7 +5695,7 @@ static int rtw_wx_set_priv(struct net_device *dev, FREE_EXT: - rtw_vmfree(ext, len); + vfree(ext); return ret; } diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 02f5e0c90f9a..622b70c39ce0 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -55,11 +55,6 @@ u32 rtw_atoi(u8 *s) return num; } -inline void _rtw_vmfree(u8 *pbuf, u32 sz) -{ - vfree(pbuf); -} - u8 *_rtw_malloc(u32 sz) { u8 *pbuf = NULL; @@ -260,7 +255,7 @@ void rtw_free_netdev(struct net_device *netdev) if (!pnpi->priv) goto RETURN; - rtw_vmfree(pnpi->priv, pnpi->sizeof_priv); + vfree(pnpi->priv); free_netdev(netdev); RETURN: diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index e5539dd63719..0a585b2a924a 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -746,7 +746,7 @@ free_adapter: if (pnetdev) rtw_free_netdev(pnetdev); else if (padapter) - rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + vfree(padapter); padapter = NULL; } exit: From 9b4a2b7e28152c445f0ecc9d1b7e1381b0cd23c0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:44 -0600 Subject: [PATCH 0080/1375] staging: r8188eu: Remove ODM_AllocateMemory This wrapper for vzalloc() is not used. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_interface.c | 6 ------ drivers/staging/rtl8188eu/include/odm_interface.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 568c73476f8c..0f5b32fb63a7 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -20,12 +20,6 @@ #include "odm_precomp.h" -/* ODM Memory relative API. */ -void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) -{ - *pPtr = vzalloc(length); -} - s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) { return _rtw_memcmp(pBuf1, pBuf2, length); diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index eb96d7a6d5ad..8e077549e875 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -78,7 +78,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* =========== EXtern Function Prototype */ /* Memory Relative Function. */ -void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length); s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length); From 0e848068359d8c7919d2574bffcc1af5c9e5c7e7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:45 -0600 Subject: [PATCH 0081/1375] staging: r8188eu: Remove ODM_CompareMemory This routine is a wrapper for _rtw_memcmp(), which is a wrapper for memcmp. In a later change, _rtw_memcmp will be removed. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c | 4 ++-- drivers/staging/rtl8188eu/hal/odm_interface.c | 5 ----- drivers/staging/rtl8188eu/include/odm_interface.h | 3 --- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index 6af70ce93ac8..4b5caa1f397a 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -217,7 +217,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( for (i = 0; i < CCK_TABLE_SIZE; i++) { if (dm_odm->RFCalibrateInfo.bCCKinCH14) { - if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { + if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { CCK_index_old = (u8)i; dm_odm->BbSwingIdxCckBase = (u8)i; ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, @@ -229,7 +229,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RegA24: 0x%X, CCKSwingTable_Ch1_Ch13[%d][2]: CCKSwingTable_Ch1_Ch13[i][2]: 0x%X\n", TempCCk, i, CCKSwingTable_Ch1_Ch13[i][2])); - if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { + if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { CCK_index_old = (u8)i; dm_odm->BbSwingIdxCckBase = (u8)i; ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 0f5b32fb63a7..f6e8c1c9727b 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -20,11 +20,6 @@ #include "odm_precomp.h" -s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) -{ - return _rtw_memcmp(pBuf1, pBuf2, length); -} - void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay) { _set_timer(pTimer, msDelay); /* ms */ diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 8e077549e875..35de915ba658 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -79,9 +79,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* Memory Relative Function. */ -s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, - u32 length); - /* ODM Timer relative API. */ void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay); From 3c75b6d4b5773ea67f8ce3b85948639a8e64975e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:46 -0600 Subject: [PATCH 0082/1375] staging: r8188eu: Remove ODM_SetTimer This wrapper is not used. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_interface.c | 5 ----- drivers/staging/rtl8188eu/include/odm_interface.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index f6e8c1c9727b..92dadc1f1327 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -20,11 +20,6 @@ #include "odm_precomp.h" -void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay) -{ - _set_timer(pTimer, msDelay); /* ms */ -} - void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, void *CallBackFunc, void *pContext, const char *szID) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 35de915ba658..6ecd2960deee 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -80,8 +80,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* Memory Relative Function. */ /* ODM Timer relative API. */ -void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, - u32 msDelay); void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, void *CallBackFunc, From 52a1c19d8b7e31a77abec00658fd3c1ddcf0eb04 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 6 Feb 2014 20:45:47 -0600 Subject: [PATCH 0083/1375] staging: r8188eu: Remove ODM_InitializeTimer This wrapper is not used. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_interface.c | 8 -------- drivers/staging/rtl8188eu/include/odm_interface.h | 4 ---- 2 files changed, 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 92dadc1f1327..710f8e1620db 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -20,14 +20,6 @@ #include "odm_precomp.h" -void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, - void *CallBackFunc, void *pContext, - const char *szID) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - _init_timer(pTimer, Adapter->pnetdev, CallBackFunc, pDM_Odm); -} - void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) { _cancel_timer_ex(pTimer); diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 6ecd2960deee..548a309db199 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -81,10 +81,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); /* ODM Timer relative API. */ -void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, - struct timer_list *pTimer, void *CallBackFunc, - void *pContext, const char *szID); - void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); /* ODM FW relative API. */ From e6439a458aa2805f05dd5fb3da8a95fd90082728 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 3 Feb 2014 10:43:25 -0700 Subject: [PATCH 0084/1375] staging: comedi: drivers: propogate errno from subdev_8255_init() The initialization of the 8255 subdevice can fail due to the allocation of the private data. Make sure all callers of subdev_8255_init() propogate the errno. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 10 ++++++---- drivers/staging/comedi/drivers/cb_pcidas64.c | 13 ++++++++----- drivers/staging/comedi/drivers/cb_pcimdas.c | 4 +++- drivers/staging/comedi/drivers/das08.c | 7 ++++--- drivers/staging/comedi/drivers/ni_atmio16d.c | 9 ++++++--- drivers/staging/comedi/drivers/ni_mio_common.c | 10 +++++++--- drivers/staging/comedi/drivers/pcm3724.c | 6 ++++-- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index d4bd61d84daf..2d966a87f2e8 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -1130,10 +1130,12 @@ static int pci_dio_auto_attach(struct comedi_device *dev, for (i = 0; i < MAX_DIO_SUBDEVG; i++) for (j = 0; j < this_board->sdio[i].regs; j++) { s = &dev->subdevices[subdev]; - subdev_8255_init(dev, s, NULL, - dev->iobase + - this_board->sdio[i].addr + - SIZE_8255 * j); + ret = subdev_8255_init(dev, s, NULL, + dev->iobase + + this_board->sdio[i].addr + + SIZE_8255 * j); + if (ret) + return ret; subdev++; } diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 4fff1738e3f8..464c783e566e 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3816,16 +3816,19 @@ static int setup_subdevices(struct comedi_device *dev) if (thisboard->has_8255) { if (thisboard->layout == LAYOUT_4020) { dio_8255_iobase = devpriv->main_iobase + I8255_4020_REG; - subdev_8255_init(dev, s, dio_callback_4020, - (unsigned long)dio_8255_iobase); + ret = subdev_8255_init(dev, s, dio_callback_4020, + (unsigned long)dio_8255_iobase); } else { dio_8255_iobase = devpriv->dio_counter_iobase + DIO_8255_OFFSET; - subdev_8255_init(dev, s, dio_callback, - (unsigned long)dio_8255_iobase); + ret = subdev_8255_init(dev, s, dio_callback, + (unsigned long)dio_8255_iobase); } - } else + if (ret) + return ret; + } else { s->type = COMEDI_SUBD_UNUSED; + } /* 8 channel dio for 60xx */ s = &dev->subdevices[5]; diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 57295d189ff6..8bf344cd46de 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -247,7 +247,9 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; /* digital i/o subdevice */ - subdev_8255_init(dev, s, NULL, iobase_8255); + ret = subdev_8255_init(dev, s, NULL, iobase_8255); + if (ret) + return ret; dev_info(dev->class_dev, "%s attached\n", dev->board_name); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index e5c0ee9a09c2..3c0e45837c72 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -529,9 +529,10 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s = &dev->subdevices[4]; /* 8255 */ if (thisboard->i8255_offset != 0) { - subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase + - thisboard-> - i8255_offset)); + ret = subdev_8255_init(dev, s, NULL, + dev->iobase + thisboard->i8255_offset); + if (ret) + return ret; } else { s->type = COMEDI_SUBD_UNUSED; } diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index e8cd5ddb85c5..4f26aa9424b8 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -723,10 +723,13 @@ static int atmio16d_attach(struct comedi_device *dev, /* 8255 subdevice */ s = &dev->subdevices[3]; - if (board->has_8255) - subdev_8255_init(dev, s, NULL, dev->iobase); - else + if (board->has_8255) { + ret = subdev_8255_init(dev, s, NULL, dev->iobase); + if (ret) + return ret; + } else { s->type = COMEDI_SUBD_UNUSED; + } /* don't yet know how to deal with counter/timers */ #if 0 diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 10c27cb278cb..575011533a18 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4292,10 +4292,14 @@ static int ni_E_init(struct comedi_device *dev) /* 8255 device */ s = &dev->subdevices[NI_8255_DIO_SUBDEV]; - if (board->has_8255) - subdev_8255_init(dev, s, ni_8255_callback, (unsigned long)dev); - else + if (board->has_8255) { + ret = subdev_8255_init(dev, s, ni_8255_callback, + (unsigned long)dev); + if (ret) + return ret; + } else { s->type = COMEDI_SUBD_UNUSED; + } /* formerly general purpose counter/timer device, but no longer used */ s = &dev->subdevices[NI_UNUSED_SUBDEV]; diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index f4a49bd649f0..53e73737a906 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -225,8 +225,10 @@ static int pcm3724_attach(struct comedi_device *dev, for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; - subdev_8255_init(dev, s, subdev_8255_cb, - (unsigned long)(dev->iobase + SIZE_8255 * i)); + ret = subdev_8255_init(dev, s, subdev_8255_cb, + dev->iobase + SIZE_8255 * i); + if (ret) + return ret; s->insn_config = subdev_3724_insn_config; } return 0; From 46828a56f24a9121a4a3de33e1985fc4532c017c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 3 Feb 2014 10:43:26 -0700 Subject: [PATCH 0085/1375] staging: comedi: amplc_pc236: remove dev_err() message due to allocation failure The subdev_8255_init() call can only fail due to the allocation of the private data. This failure will alreay have produced an error message. Remove the redundant dev_err(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pc236.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 31734e1142fd..12eabd6b4978 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -411,10 +411,9 @@ static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase, s = &dev->subdevices[0]; /* digital i/o subdevice (8255) */ ret = subdev_8255_init(dev, s, NULL, iobase); - if (ret < 0) { - dev_err(dev->class_dev, "error! out of memory!\n"); + if (ret) return ret; - } + s = &dev->subdevices[1]; dev->read_subdev = s; s->type = COMEDI_SUBD_UNUSED; From ce921ae41919d033b4cd1d639f2a5f42dd41e802 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 3 Feb 2014 10:43:27 -0700 Subject: [PATCH 0086/1375] staging: comedi: amplc_pci230: standardize error handling of subdev_8255_init() The subdev_8255_init() call returns 0 for success of a negative errno for failure. For aesthetics, change the error test in this driver from (rc < 0) to simply (rc) to follow the style of the other users of this function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index c08dfbbe4062..8b8b2ac4bf7f 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2762,8 +2762,8 @@ static int pci230_attach_common(struct comedi_device *dev, /* digital i/o subdevice */ if (thisboard->have_dio) { rc = subdev_8255_init(dev, s, NULL, - (devpriv->iobase1 + PCI230_PPI_X_BASE)); - if (rc < 0) + devpriv->iobase1 + PCI230_PPI_X_BASE); + if (rc) return rc; } else { s->type = COMEDI_SUBD_UNUSED; From c93999c21319439c4fe2da85f2ec40ed477379ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 3 Feb 2014 11:26:50 -0700 Subject: [PATCH 0087/1375] staging: comedi: drivers: remove final 'attach' messages These messages are just added noise. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255_pci.c | 3 -- drivers/staging/comedi/drivers/adl_pci7x3x.c | 3 -- drivers/staging/comedi/drivers/adl_pci9111.c | 2 -- drivers/staging/comedi/drivers/adl_pci9118.c | 23 -------------- drivers/staging/comedi/drivers/adv_pci1710.c | 3 -- drivers/staging/comedi/drivers/adv_pci1723.c | 2 -- drivers/staging/comedi/drivers/aio_aio12_8.c | 3 -- .../comedi/drivers/amplc_dio200_common.c | 2 +- drivers/staging/comedi/drivers/amplc_pc236.c | 30 ++----------------- drivers/staging/comedi/drivers/amplc_pc263.c | 2 -- drivers/staging/comedi/drivers/amplc_pci224.c | 17 +---------- drivers/staging/comedi/drivers/amplc_pci230.c | 4 +-- drivers/staging/comedi/drivers/amplc_pci263.c | 2 -- drivers/staging/comedi/drivers/cb_das16_cs.c | 4 --- drivers/staging/comedi/drivers/cb_pcidas.c | 3 -- drivers/staging/comedi/drivers/cb_pcidda.c | 2 -- drivers/staging/comedi/drivers/cb_pcimdas.c | 2 -- drivers/staging/comedi/drivers/cb_pcimdda.c | 4 +-- .../staging/comedi/drivers/contec_pci_dio.c | 2 -- drivers/staging/comedi/drivers/daqboard2000.c | 3 -- drivers/staging/comedi/drivers/dt3000.c | 2 -- drivers/staging/comedi/drivers/dyna_pci10xx.c | 2 -- drivers/staging/comedi/drivers/icp_multi.c | 3 -- drivers/staging/comedi/drivers/ke_counter.c | 3 -- drivers/staging/comedi/drivers/me_daq.c | 3 -- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_670x.c | 3 -- drivers/staging/comedi/drivers/ni_daq_700.c | 5 ---- .../staging/comedi/drivers/ni_mio_common.c | 1 - drivers/staging/comedi/drivers/rtd520.c | 2 -- drivers/staging/comedi/drivers/s626.c | 2 -- drivers/staging/comedi/drivers/skel.c | 2 -- drivers/staging/comedi/drivers/ssv_dnp.c | 3 +- 33 files changed, 9 insertions(+), 140 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index 8a57c3c1ade0..47321de629a7 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -235,9 +235,6 @@ static int pci_8255_auto_attach(struct comedi_device *dev, return ret; } - dev_info(dev->class_dev, "%s attached (%d digital i/o channels)\n", - dev->board_name, board->n_8255 * 24); - return 0; } diff --git a/drivers/staging/comedi/drivers/adl_pci7x3x.c b/drivers/staging/comedi/drivers/adl_pci7x3x.c index 6f622b4de698..5e3cc77a8a0c 100644 --- a/drivers/staging/comedi/drivers/adl_pci7x3x.c +++ b/drivers/staging/comedi/drivers/adl_pci7x3x.c @@ -239,9 +239,6 @@ static int adl_pci7x3x_auto_attach(struct comedi_device *dev, } } - dev_info(dev->class_dev, "%s attached (%d inputs/%d outputs)\n", - dev->board_name, board->di_nchan, board->do_nchan); - return 0; } diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 363f2e42a27f..0039b1b0ec47 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -906,8 +906,6 @@ static int pci9111_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = pci9111_do_insn_bits; - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 4bdd9720e9eb..ef5afdb3bd09 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1936,28 +1936,6 @@ static struct pci_dev *pci9118_find_pci(struct comedi_device *dev, return NULL; } -static void pci9118_report_attach(struct comedi_device *dev, unsigned int irq) -{ - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct pci9118_private *devpriv = dev->private; - char irqbuf[30]; - char muxbuf[30]; - - if (irq) - snprintf(irqbuf, sizeof(irqbuf), "irq %u%s", irq, - (dev->irq ? "" : " UNAVAILABLE")); - else - snprintf(irqbuf, sizeof(irqbuf), "irq DISABLED"); - if (devpriv->usemux) - snprintf(muxbuf, sizeof(muxbuf), "ext mux %u chans", - devpriv->usemux); - else - snprintf(muxbuf, sizeof(muxbuf), "no ext mux"); - dev_info(dev->class_dev, "%s (pci %s, %s, %sbus master, %s) attached\n", - dev->board_name, pci_name(pcidev), irqbuf, - (devpriv->master ? "" : "no "), muxbuf); -} - static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, int master, int ext_mux, int softsshdelay, int hw_err_mask) @@ -2113,7 +2091,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, break; } - pci9118_report_attach(dev, dev->irq); return 0; } diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 593676cf706a..69a8298f90b9 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1347,9 +1347,6 @@ static int pci1710_auto_attach(struct comedi_device *dev, subdev++; } - dev_info(dev->class_dev, "%s attached, irq %sabled\n", - dev->board_name, dev->irq ? "en" : "dis"); - return 0; } diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 72394267ddfe..07b107d1ab33 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -280,8 +280,6 @@ static int pci1723_auto_attach(struct comedi_device *dev, pci1723_reset(dev); - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 68c3fb3226ca..e2a917786f0a 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -247,9 +247,6 @@ static int aio_aio12_8_attach(struct comedi_device *dev, /* 8254 counter/timer subdevice */ s->type = COMEDI_SUBD_UNUSED; - dev_info(dev->class_dev, "%s: %s attached\n", - dev->driver->driver_name, dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 9c9559ffc643..818a0d7e3d58 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -1208,7 +1208,7 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, "warning! irq %u unavailable!\n", irq); } } - dev_info(dev->class_dev, "attached\n"); + return 0; } EXPORT_SYMBOL_GPL(amplc_dio200_common_attach); diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 12eabd6b4978..b21d7b48f1da 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -368,32 +368,6 @@ static irqreturn_t pc236_interrupt(int irq, void *d) return IRQ_RETVAL(handled); } -static void pc236_report_attach(struct comedi_device *dev, unsigned int irq) -{ - const struct pc236_board *thisboard = comedi_board(dev); - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - char tmpbuf[60]; - int tmplen; - - if (is_isa_board(thisboard)) - tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), - "(base %#lx) ", dev->iobase); - else if (is_pci_board(thisboard)) - tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), - "(pci %s) ", pci_name(pcidev)); - else - tmplen = 0; - if (irq) - tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen, - "(irq %u%s) ", irq, - (dev->irq ? "" : " UNAVAILABLE")); - else - tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen, - "(no irq) "); - dev_info(dev->class_dev, "%s %sattached\n", - dev->board_name, tmpbuf); -} - static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase, unsigned int irq, unsigned long req_irq_flags) { @@ -433,8 +407,8 @@ static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase, s->cancel = pc236_intr_cancel; } } - pc236_report_attach(dev, irq); - return 1; + + return 0; } static int pc236_pci_common_attach(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 5b4b5ab34e2e..7c10d28d2784 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -94,8 +94,6 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* read initial relay state */ s->state = inb(dev->iobase) | (inb(dev->iobase + 1) << 8); - dev_info(dev->class_dev, "%s (base %#lx) attached\n", dev->board_name, - dev->iobase); return 0; } diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index ae4048a624fa..8be36b8afbdf 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -1237,20 +1237,6 @@ static struct pci_dev *pci224_find_pci_dev(struct comedi_device *dev, return NULL; } -static void pci224_report_attach(struct comedi_device *dev, unsigned int irq) -{ - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - char tmpbuf[30]; - - if (irq) - snprintf(tmpbuf, sizeof(tmpbuf), "irq %u%s", irq, - (dev->irq ? "" : " UNAVAILABLE")); - else - snprintf(tmpbuf, sizeof(tmpbuf), "no irq"); - dev_info(dev->class_dev, "%s (pci %s) (%s) attached\n", - dev->board_name, pci_name(pcidev), tmpbuf); -} - /* * Common part of attach and auto_attach. */ @@ -1399,8 +1385,7 @@ static int pci224_attach_common(struct comedi_device *dev, } } - pci224_report_attach(dev, irq); - return 1; + return 0; } static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 8b8b2ac4bf7f..7356fee67379 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2768,8 +2768,8 @@ static int pci230_attach_common(struct comedi_device *dev, } else { s->type = COMEDI_SUBD_UNUSED; } - dev_info(dev->class_dev, "attached\n"); - return 1; + + return 0; } static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it) diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/staging/comedi/drivers/amplc_pci263.c index be28e6cbea20..93ed03ee416a 100644 --- a/drivers/staging/comedi/drivers/amplc_pci263.c +++ b/drivers/staging/comedi/drivers/amplc_pci263.c @@ -84,8 +84,6 @@ static int pci263_auto_attach(struct comedi_device *dev, /* read initial relay state */ s->state = inb(dev->iobase) | (inb(dev->iobase + 1) << 8); - dev_info(dev->class_dev, "%s (pci %s) attached\n", dev->board_name, - pci_name(pci_dev)); return 0; } diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 64d5f291553f..9a14e26e2416 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -451,10 +451,6 @@ static int das16cs_auto_attach(struct comedi_device *dev, s->insn_bits = das16cs_dio_insn_bits; s->insn_config = das16cs_dio_insn_config; - dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx, irq=%u\n", - dev->driver->driver_name, dev->board_name, - dev->iobase, dev->irq); - return 0; } diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 9819be092f8d..69fbda7e3bc2 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1576,9 +1576,6 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS, devpriv->s5933_config + AMCC_OP_REG_INTCSR); - dev_info(dev->class_dev, "%s: %s attached\n", - dev->driver->driver_name, dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 8cca0518cfda..901dc5d1bb72 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -388,8 +388,6 @@ static int cb_pcidda_auto_attach(struct comedi_device *dev, for (i = 0; i < thisboard->ao_chans; i++) cb_pcidda_calibrate(dev, i, devpriv->ao_range[i]); - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 8bf344cd46de..3e39cb593e10 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -251,8 +251,6 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, if (ret) return ret; - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 43a86630a66e..4a2b200de01b 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -187,9 +187,7 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, if (ret) return ret; - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - - return 1; + return 0; } static struct comedi_driver cb_pcimdda_driver = { diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index 323a7f39cd97..0a9c32e9db4a 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -92,8 +92,6 @@ static int contec_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = contec_do_insn_bits; - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index ce153fcb8b2a..6ff7d3e1971a 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -737,9 +737,6 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, if (result) return result; - dev_info(dev->class_dev, "%s: %s attached\n", - dev->driver->driver_name, dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index f52a4476cb73..f54685ed463c 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -767,8 +767,6 @@ static int dt3000_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_PROC; #endif - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index f224825830ba..69157320df4e 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -232,8 +232,6 @@ static int dyna_pci10xx_auto_attach(struct comedi_device *dev, s->state = 0; s->insn_bits = dyna_pci10xx_do_insn_bits; - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index 80539b2bea1a..19c586bae04e 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -565,9 +565,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev, devpriv->valid = 1; - dev_info(dev->class_dev, "%s attached, irq %sabled\n", - dev->board_name, dev->irq ? "en" : "dis"); - return 0; } diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index 6b9846fd8c48..1c32816e9130 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -119,9 +119,6 @@ static int cnt_auto_attach(struct comedi_device *dev, outb(0, dev->iobase + 0x20); outb(0, dev->iobase + 0x40); - dev_info(dev->class_dev, "%s: %s attached\n", - dev->driver->driver_name, dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 7f6687896401..288ce2b16e8f 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -542,9 +542,6 @@ static int me_auto_attach(struct comedi_device *dev, s->insn_bits = me_dio_insn_bits; s->insn_config = me_dio_insn_config; - dev_info(dev->class_dev, "%s: %s attached\n", - dev->driver->driver_name, dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index df42e3906171..b8c3fbe25b21 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -1187,7 +1187,7 @@ static int ni_660x_auto_attach(struct comedi_device *dev, global_interrupt_config_bits |= Cascade_Int_Enable_Bit; ni_660x_write_register(dev, 0, global_interrupt_config_bits, NI660X_GLOBAL_INT_CFG); - dev_info(dev->class_dev, "ni_660x: %s attached\n", dev->board_name); + return 0; } diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 8550fdc4ccd3..1002ceacfdcc 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -246,9 +246,6 @@ static int ni_670x_auto_attach(struct comedi_device *dev, /* Config of ao registers */ writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET); - dev_info(dev->class_dev, "%s: %s attached\n", - dev->driver->driver_name, dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index e4cdca349157..7979a6610426 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -229,11 +229,6 @@ static int daq700_auto_attach(struct comedi_device *dev, s->insn_read = daq700_ai_rinsn; daq700_ai_config(dev, s); - dev_info(dev->class_dev, "%s: %s, io 0x%lx\n", - dev->driver->driver_name, - dev->board_name, - dev->iobase); - return 0; } diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 575011533a18..8adb535516bd 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4497,7 +4497,6 @@ static int ni_E_init(struct comedi_device *dev) ni_writeb(0x0, M_Offset_AO_Calibration); } - printk("\n"); return 0; } diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 0f026afde9be..0e83e7e80b49 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1382,8 +1382,6 @@ static int rtd_auto_attach(struct comedi_device *dev, if (dev->irq) writel(ICS_PIE | ICS_PLIE, devpriv->lcfg + PLX_INTRCS_REG); - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 19da1dbea494..9e711ee13bb7 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2902,8 +2902,6 @@ static int s626_auto_attach(struct comedi_device *dev, s626_initialize(dev); - dev_info(dev->class_dev, "%s attached\n", dev->board_name); - return 0; } diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 77e2059ff62e..e800e73738ee 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -456,8 +456,6 @@ static int skel_common_attach(struct comedi_device *dev) s->type = COMEDI_SUBD_UNUSED; } - dev_info(dev->class_dev, "skel: attached\n"); - return 0; } diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index df22a78d2b7e..848c30801580 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -161,8 +161,7 @@ static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it) outb(PCMR, CSCIR); outb((inb(CSCDR) & 0xAA), CSCDR); - dev_info(dev->class_dev, "%s: attached\n", dev->board_name); - return 1; + return 0; } static void dnp_detach(struct comedi_device *dev) From fb780d213355868b69cc12142635aae5e0ee7c2a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 3 Feb 2014 11:26:51 -0700 Subject: [PATCH 0088/1375] staging: comedi: drivers: return '0' for successful attach The comedi core expects the driver attach functions to return a negative errno for failure. Any other value indicates success. For consistency in the drivers, make sure they all return '0' to indicate success. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/aio_iiro_16.c | 2 +- drivers/staging/comedi/drivers/fl512.c | 2 +- drivers/staging/comedi/drivers/jr3_pci.c | 2 +- drivers/staging/comedi/drivers/mpc624.c | 2 +- drivers/staging/comedi/drivers/ni_pcimio.c | 2 +- drivers/staging/comedi/drivers/s526.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 22b3dda135ff..781104aa533e 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -98,7 +98,7 @@ static int aio_iiro_16_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = aio_iiro_16_dio_insn_bits_read; - return 1; + return 0; } static struct comedi_driver aio_iiro_16_driver = { diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index a99ddf00ddc4..a5562ea2806f 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -159,7 +159,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* function to call when reading DA */ s->insn_read = fl512_ao_insn_readback; - return 1; + return 0; } static struct comedi_driver fl512_driver = { diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 6100c12c164f..73ef31ebc05d 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -773,7 +773,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, devpriv->timer.expires = jiffies + msecs_to_jiffies(1000); add_timer(&devpriv->timer); - return result; + return 0; } static void jr3_pci_detach(struct comedi_device *dev) diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index fe4621ea65c3..59ad8391cdc8 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -341,7 +341,7 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->len_chanlist = 1; s->insn_read = mpc624_ai_rinsn; - return 1; + return 0; } static struct comedi_driver mpc624_driver = { diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 0ed980455875..d40df072583c 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1551,7 +1551,7 @@ static int pcimio_auto_attach(struct comedi_device *dev, dev->subdevices[NI_GPCT_SUBDEV(1)].buf_change = &pcimio_gpct1_change; dev->subdevices[NI_DIO_SUBDEV].buf_change = &pcimio_dio_change; - return ret; + return 0; } static int pcimio_ai_change(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 9950f59b1192..0a93afab3dcb 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -604,7 +604,7 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->insn_bits = s526_dio_insn_bits; s->insn_config = s526_dio_insn_config; - return 1; + return 0; } static struct comedi_driver s526_driver = { From 3b92e8ae303f8df6a30690358876692d979bd6dc Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Tue, 21 Jan 2014 12:18:34 -0700 Subject: [PATCH 0089/1375] staging/usbip: remove vhci_hcd vhci_hub_status change message When vhci_hcd is enabled, the following message floods the dmesg buffer. This message doesn't provide any useful information other than cluttering the dmesg buffer. Fix it by removing the message. There is another debug message in this routine that dumps detailed port status change information. [ 4062.716662] vhci_hcd: changed 0 Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/vhci_hcd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 72391ef87646..adb6201479dc 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -205,8 +205,6 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) } } - pr_info("changed %d\n", changed); - if ((hcd->state == HC_STATE_SUSPENDED) && (changed == 1)) usb_hcd_resume_root_hub(hcd); From a6646ea683c0c73962cb67aea9be40b11b916de5 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Wed, 22 Jan 2014 14:24:29 -0700 Subject: [PATCH 0090/1375] staging/usbip: Change vhci_hcd store_attach() device information message to include speed string Change vhci_hcd store_attach() routine to include speed string in its device information message. The current call to dev_info() prints out speed number which is the enum number. Change to call usb_speed_string() to print speed string in addition to the number. Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/vhci_sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c index 9b51586d11d9..742309222103 100644 --- a/drivers/staging/usbip/vhci_sysfs.c +++ b/drivers/staging/usbip/vhci_sysfs.c @@ -214,8 +214,9 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, return -EINVAL; } - dev_info(dev, "rhport(%u) sockfd(%d) devid(%u) speed(%u)\n", - rhport, sockfd, devid, speed); + dev_info(dev, + "rhport(%u) sockfd(%d) devid(%u) speed(%u) speed_str(%s)\n", + rhport, sockfd, devid, speed, usb_speed_string(speed)); vdev->devid = devid; vdev->speed = speed; From b7945b77cd03094458f3624bc82a27e0d36e75d0 Mon Sep 17 00:00:00 2001 From: Valentina Manea Date: Thu, 23 Jan 2014 23:12:29 +0200 Subject: [PATCH 0091/1375] staging: usbip: convert usbip-host driver to usb_device_driver This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver. This patch also modifies the way userspace sees and uses a shared device: * the usbip_status file is no longer created for interface 0, but for the whole device (such as /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1/usbip_status). * per interface information, such as interface class or protocol, is no longer sent/received; only device specific information is transmitted. * since the driver was moved one level below in the USB architecture, there is no need to bind/unbind each interface, just the device as a whole. Signed-off-by: Valentina Manea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub.h | 2 +- drivers/staging/usbip/stub_dev.c | 150 ++++++----------- drivers/staging/usbip/stub_main.c | 6 +- drivers/staging/usbip/stub_rx.c | 2 +- .../userspace/libsrc/usbip_host_driver.c | 45 ++--- .../staging/usbip/userspace/src/usbip_bind.c | 154 +++++++----------- .../staging/usbip/userspace/src/usbip_list.c | 19 +-- .../usbip/userspace/src/usbip_unbind.c | 51 ++---- drivers/staging/usbip/userspace/src/usbipd.c | 15 -- drivers/usb/core/generic.c | 1 + drivers/usb/core/message.c | 1 + include/linux/usb.h | 4 + 12 files changed, 156 insertions(+), 294 deletions(-) diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h index a73e437ec215..82e539a4fcff 100644 --- a/drivers/staging/usbip/stub.h +++ b/drivers/staging/usbip/stub.h @@ -93,7 +93,7 @@ struct bus_id_priv { extern struct kmem_cache *stub_priv_cache; /* stub_dev.c */ -extern struct usb_driver stub_driver; +extern struct usb_device_driver stub_driver; /* stub_main.c */ struct bus_id_priv *get_busid_priv(const char *busid); diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 76a1ff0e6275..b0bfd3430d47 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -279,21 +279,19 @@ static void stub_device_unusable(struct usbip_device *ud) * * Allocates and initializes a new stub_device struct. */ -static struct stub_device *stub_device_alloc(struct usb_device *udev, - struct usb_interface *interface) +static struct stub_device *stub_device_alloc(struct usb_device *udev) { struct stub_device *sdev; - int busnum = interface_to_busnum(interface); - int devnum = interface_to_devnum(interface); + int busnum = udev->bus->busnum; + int devnum = udev->devnum; - dev_dbg(&interface->dev, "allocating stub device"); + dev_dbg(&udev->dev, "allocating stub device"); /* yes, it's a new device */ sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL); if (!sdev) return NULL; - sdev->interface = usb_get_intf(interface); sdev->udev = usb_get_dev(udev); /* @@ -322,7 +320,7 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev, usbip_start_eh(&sdev->ud); - dev_dbg(&interface->dev, "register new interface\n"); + dev_dbg(&udev->dev, "register new device\n"); return sdev; } @@ -332,32 +330,20 @@ static void stub_device_free(struct stub_device *sdev) kfree(sdev); } -/* - * If a usb device has multiple active interfaces, this driver is bound to all - * the active interfaces. However, usbip exports *a* usb device (i.e., not *an* - * active interface). Currently, a userland program must ensure that it - * looks at the usbip's sysfs entries of only the first active interface. - * - * TODO: use "struct usb_device_driver" to bind a usb device. - * However, it seems it is not fully supported in mainline kernel yet - * (2.6.19.2). - */ -static int stub_probe(struct usb_interface *interface, - const struct usb_device_id *id) +static int stub_probe(struct usb_device *udev) { - struct usb_device *udev = interface_to_usbdev(interface); struct stub_device *sdev = NULL; - const char *udev_busid = dev_name(interface->dev.parent); - int err = 0; + const char *udev_busid = dev_name(&udev->dev); + int err = 0, config; struct bus_id_priv *busid_priv; - dev_dbg(&interface->dev, "Enter\n"); + dev_dbg(&udev->dev, "Enter\n"); /* check we should claim or not by busid_table */ busid_priv = get_busid_priv(udev_busid); if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || (busid_priv->status == STUB_BUSID_OTHER)) { - dev_info(&interface->dev, + dev_info(&udev->dev, "%s is not in match_busid table... skip!\n", udev_busid); @@ -383,60 +369,36 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; } - if (busid_priv->status == STUB_BUSID_ALLOC) { - sdev = busid_priv->sdev; - if (!sdev) - return -ENODEV; - - busid_priv->interf_count++; - dev_info(&interface->dev, - "usbip-host: register new interface (bus %u dev %u ifn %u)\n", - udev->bus->busnum, udev->devnum, - interface->cur_altsetting->desc.bInterfaceNumber); - - /* set private data to usb_interface */ - usb_set_intfdata(interface, sdev); - - err = stub_add_files(&interface->dev); - if (err) { - dev_err(&interface->dev, "stub_add_files for %s\n", - udev_busid); - usb_set_intfdata(interface, NULL); - busid_priv->interf_count--; - return err; - } - - usb_get_intf(interface); - return 0; - } - /* ok, this is my device */ - sdev = stub_device_alloc(udev, interface); + sdev = stub_device_alloc(udev); if (!sdev) return -ENOMEM; - dev_info(&interface->dev, - "usbip-host: register new device (bus %u dev %u ifn %u)\n", - udev->bus->busnum, udev->devnum, - interface->cur_altsetting->desc.bInterfaceNumber); + dev_info(&udev->dev, + "usbip-host: register new device (bus %u dev %u)\n", + udev->bus->busnum, udev->devnum); - busid_priv->interf_count = 0; busid_priv->shutdown_busid = 0; - /* set private data to usb_interface */ - usb_set_intfdata(interface, sdev); - busid_priv->interf_count++; + config = usb_choose_configuration(udev); + if (config >= 0) { + err = usb_set_configuration(udev, config); + if (err && err != -ENODEV) + dev_err(&udev->dev, "can't set config #%d, error %d\n", + config, err); + } + + /* set private data to usb_device */ + dev_set_drvdata(&udev->dev, sdev); busid_priv->sdev = sdev; - err = stub_add_files(&interface->dev); + err = stub_add_files(&udev->dev); if (err) { - dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); - usb_set_intfdata(interface, NULL); - usb_put_intf(interface); + dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid); + dev_set_drvdata(&udev->dev, NULL); usb_put_dev(udev); kthread_stop_put(sdev->ud.eh); - busid_priv->interf_count = 0; busid_priv->sdev = NULL; stub_device_free(sdev); return err; @@ -461,13 +423,13 @@ static void shutdown_busid(struct bus_id_priv *busid_priv) * called in usb_disconnect() or usb_deregister() * but only if actconfig(active configuration) exists */ -static void stub_disconnect(struct usb_interface *interface) +static void stub_disconnect(struct usb_device *udev) { struct stub_device *sdev; - const char *udev_busid = dev_name(interface->dev.parent); + const char *udev_busid = dev_name(&udev->dev); struct bus_id_priv *busid_priv; - dev_dbg(&interface->dev, "Enter\n"); + dev_dbg(&udev->dev, "Enter\n"); busid_priv = get_busid_priv(udev_busid); if (!busid_priv) { @@ -475,41 +437,29 @@ static void stub_disconnect(struct usb_interface *interface) return; } - sdev = usb_get_intfdata(interface); + sdev = dev_get_drvdata(&udev->dev); /* get stub_device */ if (!sdev) { - dev_err(&interface->dev, "could not get device"); + dev_err(&udev->dev, "could not get device"); return; } - usb_set_intfdata(interface, NULL); + dev_set_drvdata(&udev->dev, NULL); /* * NOTE: rx/tx threads are invoked for each usb_device. */ - stub_remove_files(&interface->dev); + stub_remove_files(&udev->dev); /* If usb reset is called from event handler */ - if (busid_priv->sdev->ud.eh == current) { - busid_priv->interf_count--; + if (busid_priv->sdev->ud.eh == current) return; - } - - if (busid_priv->interf_count > 1) { - busid_priv->interf_count--; - shutdown_busid(busid_priv); - usb_put_intf(interface); - return; - } - - busid_priv->interf_count = 0; /* shutdown the current connection */ shutdown_busid(busid_priv); usb_put_dev(sdev->udev); - usb_put_intf(interface); /* free sdev */ busid_priv->sdev = NULL; @@ -523,28 +473,34 @@ static void stub_disconnect(struct usb_interface *interface) } } -/* - * Presence of pre_reset and post_reset prevents the driver from being unbound - * when the device is being reset - */ +#ifdef CONFIG_PM -static int stub_pre_reset(struct usb_interface *interface) +/* These functions need usb_port_suspend and usb_port_resume, + * which reside in drivers/usb/core/usb.h. Skip for now. */ + +static int stub_suspend(struct usb_device *udev, pm_message_t message) { - dev_dbg(&interface->dev, "pre_reset\n"); + dev_dbg(&udev->dev, "stub_suspend\n"); + return 0; } -static int stub_post_reset(struct usb_interface *interface) +static int stub_resume(struct usb_device *udev, pm_message_t message) { - dev_dbg(&interface->dev, "post_reset\n"); + dev_dbg(&udev->dev, "stub_resume\n"); + return 0; } -struct usb_driver stub_driver = { +#endif /* CONFIG_PM */ + +struct usb_device_driver stub_driver = { .name = "usbip-host", .probe = stub_probe, .disconnect = stub_disconnect, - .id_table = stub_table, - .pre_reset = stub_pre_reset, - .post_reset = stub_post_reset, +#ifdef CONFIG_PM + .suspend = stub_suspend, + .resume = stub_resume, +#endif + .supports_autosuspend = 0, }; diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index baf857f7cc88..bd7b83a9d758 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -254,7 +254,7 @@ static int __init usbip_host_init(void) return -ENOMEM; } - ret = usb_register(&stub_driver); + ret = usb_register_device_driver(&stub_driver, THIS_MODULE); if (ret) { pr_err("usb_register failed %d\n", ret); goto err_usb_register; @@ -271,7 +271,7 @@ static int __init usbip_host_init(void) return ret; err_create_file: - usb_deregister(&stub_driver); + usb_deregister_device_driver(&stub_driver); err_usb_register: kmem_cache_destroy(stub_priv_cache); return ret; @@ -286,7 +286,7 @@ static void __exit usbip_host_exit(void) * deregister() calls stub_disconnect() for all devices. Device * specific data is cleared in stub_disconnect(). */ - usb_deregister(&stub_driver); + usb_deregister_device_driver(&stub_driver); kmem_cache_destroy(stub_priv_cache); } diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index 5d1d4a183300..76e44d949232 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -550,7 +550,7 @@ static void stub_rx_pdu(struct usbip_device *ud) int ret; struct usbip_header pdu; struct stub_device *sdev = container_of(ud, struct stub_device, ud); - struct device *dev = &sdev->interface->dev; + struct device *dev = &sdev->udev->dev; usbip_dbg_stub_rx("Enter\n"); diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c index 71a449cf50db..86a867582de6 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c @@ -32,7 +32,6 @@ struct usbip_host_driver *host_driver; #define SYSFS_OPEN_RETRIES 100 -/* only the first interface value is true! */ static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) { char attrpath[SYSFS_PATH_MAX]; @@ -56,8 +55,8 @@ static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) * usbip_status to reappear. */ - snprintf(attrpath, SYSFS_PATH_MAX, "%s/%s:%d.%d/usbip_status", - udev->path, udev->busid, udev->bConfigurationValue, 0); + snprintf(attrpath, SYSFS_PATH_MAX, "%s/usbip_status", + udev->path); while (retries > 0) { if (stat(attrpath, &s) == 0) @@ -168,19 +167,18 @@ static void delete_nothing(void *unused_data) static int refresh_exported_devices(void) { - /* sysfs_device of usb_interface */ - struct sysfs_device *suintf; - struct dlist *suintf_list; /* sysfs_device of usb_device */ struct sysfs_device *sudev; struct dlist *sudev_list; + struct dlist *sudev_unique_list; struct usbip_exported_device *edev; - sudev_list = dlist_new_with_delete(sizeof(struct sysfs_device), - delete_nothing); + sudev_unique_list = dlist_new_with_delete(sizeof(struct sysfs_device), + delete_nothing); - suintf_list = sysfs_get_driver_devices(host_driver->sysfs_driver); - if (!suintf_list) { + sudev_list = sysfs_get_driver_devices(host_driver->sysfs_driver); + + if (!sudev_list) { /* * Not an error condition. There are simply no devices bound to * the driver yet. @@ -190,23 +188,13 @@ static int refresh_exported_devices(void) return 0; } - /* collect unique USB devices (not interfaces) */ - dlist_for_each_data(suintf_list, suintf, struct sysfs_device) { - /* get usb device of this usb interface */ - sudev = sysfs_get_device_parent(suintf); - if (!sudev) { - dbg("sysfs_get_device_parent failed: %s", suintf->name); - continue; - } + dlist_for_each_data(sudev_list, sudev, struct sysfs_device) + if (check_new(sudev_unique_list, sudev)) + dlist_unshift(sudev_unique_list, sudev); - if (check_new(sudev_list, sudev)) { - /* insert item at head of list */ - dlist_unshift(sudev_list, sudev); - } - } - - dlist_for_each_data(sudev_list, sudev, struct sysfs_device) { + dlist_for_each_data(sudev_unique_list, sudev, struct sysfs_device) { edev = usbip_exported_device_new(sudev->path); + if (!edev) { dbg("usbip_exported_device_new failed"); continue; @@ -216,7 +204,7 @@ static int refresh_exported_devices(void) host_driver->ndevs++; } - dlist_destroy(sudev_list); + dlist_destroy(sudev_unique_list); return 0; } @@ -356,9 +344,8 @@ int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd) } /* only the first interface is true */ - snprintf(attr_path, sizeof(attr_path), "%s/%s:%d.%d/%s", - edev->udev.path, edev->udev.busid, - edev->udev.bConfigurationValue, 0, attr_name); + snprintf(attr_path, sizeof(attr_path), "%s/%s", + edev->udev.path, attr_name); attr = sysfs_open_attribute(attr_path); if (!attr) { diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/drivers/staging/usbip/userspace/src/usbip_bind.c index 9ecaf6e574df..8cfd2dbd9510 100644 --- a/drivers/staging/usbip/userspace/src/usbip_bind.c +++ b/drivers/staging/usbip/userspace/src/usbip_bind.c @@ -52,12 +52,8 @@ static int bind_usbip(char *busid) char attr_name[] = "bind"; char sysfs_mntpath[SYSFS_PATH_MAX]; char bind_attr_path[SYSFS_PATH_MAX]; - char intf_busid[SYSFS_BUS_ID_SIZE]; - struct sysfs_device *busid_dev; struct sysfs_attribute *bind_attr; - struct sysfs_attribute *bConfValue; - struct sysfs_attribute *bNumIntfs; - int i, failed = 0; + int failed = 0; int rc, ret = -1; rc = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX); @@ -76,39 +72,15 @@ static int bind_usbip(char *busid) return -1; } - busid_dev = sysfs_open_device(bus_type, busid); - if (!busid_dev) { - dbg("sysfs_open_device %s failed: %s", busid, strerror(errno)); - goto err_close_bind_attr; - } - - bConfValue = sysfs_get_device_attr(busid_dev, "bConfigurationValue"); - bNumIntfs = sysfs_get_device_attr(busid_dev, "bNumInterfaces"); - - if (!bConfValue || !bNumIntfs) { - dbg("problem getting device attributes: %s", - strerror(errno)); - goto err_close_busid_dev; - } - - for (i = 0; i < atoi(bNumIntfs->value); i++) { - snprintf(intf_busid, SYSFS_BUS_ID_SIZE, "%s:%.1s.%d", busid, - bConfValue->value, i); - - rc = sysfs_write_attribute(bind_attr, intf_busid, - SYSFS_BUS_ID_SIZE); - if (rc < 0) { - dbg("bind driver at %s failed", intf_busid); - failed = 1; - } + rc = sysfs_write_attribute(bind_attr, busid, SYSFS_BUS_ID_SIZE); + if (rc < 0) { + dbg("bind driver at %s failed", busid); + failed = 1; } if (!failed) ret = 0; -err_close_busid_dev: - sysfs_close_device(busid_dev); -err_close_bind_attr: sysfs_close_attribute(bind_attr); return ret; @@ -118,15 +90,12 @@ err_close_bind_attr: static int unbind_other(char *busid) { char bus_type[] = "usb"; - char intf_busid[SYSFS_BUS_ID_SIZE]; struct sysfs_device *busid_dev; - struct sysfs_device *intf_dev; - struct sysfs_driver *intf_drv; + struct sysfs_device *dev; + struct sysfs_driver *drv; struct sysfs_attribute *unbind_attr; - struct sysfs_attribute *bConfValue; struct sysfs_attribute *bDevClass; - struct sysfs_attribute *bNumIntfs; - int i, rc; + int rc; enum unbind_status status = UNBIND_ST_OK; busid_dev = sysfs_open_device(bus_type, busid); @@ -134,12 +103,11 @@ static int unbind_other(char *busid) dbg("sysfs_open_device %s failed: %s", busid, strerror(errno)); return -1; } + dbg("busid path: %s", busid_dev->path); - bConfValue = sysfs_get_device_attr(busid_dev, "bConfigurationValue"); bDevClass = sysfs_get_device_attr(busid_dev, "bDeviceClass"); - bNumIntfs = sysfs_get_device_attr(busid_dev, "bNumInterfaces"); - if (!bConfValue || !bDevClass || !bNumIntfs) { - dbg("problem getting device attributes: %s", + if (!bDevClass) { + dbg("problem getting device attribute: %s", strerror(errno)); goto err_close_busid_dev; } @@ -149,62 +117,62 @@ static int unbind_other(char *busid) goto err_close_busid_dev; } - for (i = 0; i < atoi(bNumIntfs->value); i++) { - snprintf(intf_busid, SYSFS_BUS_ID_SIZE, "%s:%.1s.%d", busid, - bConfValue->value, i); - intf_dev = sysfs_open_device(bus_type, intf_busid); - if (!intf_dev) { - dbg("could not open interface device: %s", - strerror(errno)); - goto err_close_busid_dev; - } - - dbg("%s -> %s", intf_dev->name, intf_dev->driver_name); - - if (!strncmp("unknown", intf_dev->driver_name, SYSFS_NAME_LEN)) - /* unbound interface */ - continue; - - if (!strncmp(USBIP_HOST_DRV_NAME, intf_dev->driver_name, - SYSFS_NAME_LEN)) { - /* already bound to usbip-host */ - status = UNBIND_ST_USBIP_HOST; - continue; - } - - /* unbinding */ - intf_drv = sysfs_open_driver(bus_type, intf_dev->driver_name); - if (!intf_drv) { - dbg("could not open interface driver on %s: %s", - intf_dev->name, strerror(errno)); - goto err_close_intf_dev; - } - - unbind_attr = sysfs_get_driver_attr(intf_drv, "unbind"); - if (!unbind_attr) { - dbg("problem getting interface driver attribute: %s", - strerror(errno)); - goto err_close_intf_drv; - } - - rc = sysfs_write_attribute(unbind_attr, intf_dev->bus_id, - SYSFS_BUS_ID_SIZE); - if (rc < 0) { - /* NOTE: why keep unbinding other interfaces? */ - dbg("unbind driver at %s failed", intf_dev->bus_id); - status = UNBIND_ST_FAILED; - } - - sysfs_close_driver(intf_drv); - sysfs_close_device(intf_dev); + dev = sysfs_open_device(bus_type, busid); + if (!dev) { + dbg("could not open device: %s", + strerror(errno)); + goto err_close_busid_dev; } + dbg("%s -> %s", dev->name, dev->driver_name); + + if (!strncmp("unknown", dev->driver_name, SYSFS_NAME_LEN)) { + /* unbound interface */ + sysfs_close_device(dev); + goto out; + } + + if (!strncmp(USBIP_HOST_DRV_NAME, dev->driver_name, + SYSFS_NAME_LEN)) { + /* already bound to usbip-host */ + status = UNBIND_ST_USBIP_HOST; + sysfs_close_device(dev); + goto out; + } + + /* unbinding */ + drv = sysfs_open_driver(bus_type, dev->driver_name); + if (!drv) { + dbg("could not open device driver on %s: %s", + dev->name, strerror(errno)); + goto err_close_intf_dev; + } + dbg("device driver: %s", drv->path); + + unbind_attr = sysfs_get_driver_attr(drv, "unbind"); + if (!unbind_attr) { + dbg("problem getting device driver attribute: %s", + strerror(errno)); + goto err_close_intf_drv; + } + + rc = sysfs_write_attribute(unbind_attr, dev->bus_id, + SYSFS_BUS_ID_SIZE); + if (rc < 0) { + /* NOTE: why keep unbinding other interfaces? */ + dbg("unbind driver at %s failed", dev->bus_id); + status = UNBIND_ST_FAILED; + } + + sysfs_close_driver(drv); + sysfs_close_device(dev); + goto out; err_close_intf_drv: - sysfs_close_driver(intf_drv); + sysfs_close_driver(drv); err_close_intf_dev: - sysfs_close_device(intf_dev); + sysfs_close_device(dev); err_close_busid_dev: status = UNBIND_ST_FAILED; out: diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c index 237e099337a1..8864fa2a7f0b 100644 --- a/drivers/staging/usbip/userspace/src/usbip_list.c +++ b/drivers/staging/usbip/userspace/src/usbip_list.c @@ -52,9 +52,8 @@ static int get_exported_devices(char *host, int sockfd) struct op_devlist_reply reply; uint16_t code = OP_REP_DEVLIST; struct usbip_usb_device udev; - struct usbip_usb_interface uintf; unsigned int i; - int j, rc; + int rc; rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0); if (rc < 0) { @@ -104,22 +103,6 @@ static int get_exported_devices(char *host, int sockfd) printf("%11s: %s\n", "", udev.path); printf("%11s: %s\n", "", class_name); - for (j = 0; j < udev.bNumInterfaces; j++) { - rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf)); - if (rc < 0) { - dbg("usbip_net_recv failed: usbip_usb_intf[%d]", - j); - - return -1; - } - usbip_net_pack_usb_interface(0, &uintf); - - usbip_names_get_class(class_name, sizeof(class_name), - uintf.bInterfaceClass, - uintf.bInterfaceSubClass, - uintf.bInterfaceProtocol); - printf("%11s: %2d - %s\n", "", j, class_name); - } printf("\n"); } diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c b/drivers/staging/usbip/userspace/src/usbip_unbind.c index d5a9ab6af2a6..cace87838c24 100644 --- a/drivers/staging/usbip/userspace/src/usbip_unbind.c +++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c @@ -47,12 +47,10 @@ static int unbind_device(char *busid) int verified = 0; int rc, ret = -1; - char attr_name[] = "bConfigurationValue"; + char attr_name[] = "unbind"; char sysfs_mntpath[SYSFS_PATH_MAX]; - char busid_attr_path[SYSFS_PATH_MAX]; - struct sysfs_attribute *busid_attr; - char *val = NULL; - int len; + char unbind_attr_path[SYSFS_PATH_MAX]; + struct sysfs_attribute *unbind_attr; /* verify the busid device is using usbip-host */ usbip_host_drv = sysfs_open_driver(bus_type, USBIP_HOST_DRV_NAME); @@ -99,55 +97,34 @@ static int unbind_device(char *busid) return -1; } - snprintf(busid_attr_path, sizeof(busid_attr_path), "%s/%s/%s/%s/%s/%s", - sysfs_mntpath, SYSFS_BUS_NAME, bus_type, SYSFS_DEVICES_NAME, - busid, attr_name); + snprintf(unbind_attr_path, sizeof(unbind_attr_path), "%s/%s/%s/%s/%s/%s", + sysfs_mntpath, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME, + USBIP_HOST_DRV_NAME, attr_name); /* read a device attribute */ - busid_attr = sysfs_open_attribute(busid_attr_path); - if (!busid_attr) { + unbind_attr = sysfs_open_attribute(unbind_attr_path); + if (!unbind_attr) { err("could not open %s/%s: %s", busid, attr_name, strerror(errno)); return -1; } - if (sysfs_read_attribute(busid_attr) < 0) { - err("problem reading attribute: %s", strerror(errno)); - goto err_out; - } - - len = busid_attr->len; - val = malloc(len); - *val = *busid_attr->value; - sysfs_close_attribute(busid_attr); - /* notify driver of unbind */ rc = modify_match_busid(busid, 0); if (rc < 0) { err("unable to unbind device on %s", busid); - goto err_out; } - /* write the device attribute */ - busid_attr = sysfs_open_attribute(busid_attr_path); - if (!busid_attr) { - err("could not open %s/%s: %s", busid, attr_name, - strerror(errno)); - return -1; - } - - rc = sysfs_write_attribute(busid_attr, val, len); - if (rc < 0) { - err("problem writing attribute: %s", strerror(errno)); - goto err_out; - } - sysfs_close_attribute(busid_attr); + rc = sysfs_write_attribute(unbind_attr, busid, + SYSFS_BUS_ID_SIZE); + if (rc < 0) { + dbg("bind driver at %s failed", busid); + } + sysfs_close_attribute(unbind_attr); ret = 0; printf("unbind device on busid %s: complete\n", busid); -err_out: - free(val); err_close_usbip_host_drv: sysfs_close_driver(usbip_host_drv); diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 7980f8b5517b..c2b3ced9ca6e 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -159,9 +159,7 @@ static int send_reply_devlist(int connfd) { struct usbip_exported_device *edev; struct usbip_usb_device pdu_udev; - struct usbip_usb_interface pdu_uinf; struct op_devlist_reply reply; - int i; int rc; reply.ndev = 0; @@ -196,19 +194,6 @@ static int send_reply_devlist(int connfd) dbg("usbip_net_send failed: pdu_udev"); return -1; } - - for (i = 0; i < edev->udev.bNumInterfaces; i++) { - dump_usb_interface(&edev->uinf[i]); - memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf)); - usbip_net_pack_usb_interface(1, &pdu_uinf); - - rc = usbip_net_send(connfd, &pdu_uinf, - sizeof(pdu_uinf)); - if (rc < 0) { - dbg("usbip_net_send failed: pdu_uinf"); - return -1; - } - } } return 0; diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index acbfeb0a0119..358ca8dd784f 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c @@ -155,6 +155,7 @@ int usb_choose_configuration(struct usb_device *udev) } return i; } +EXPORT_SYMBOL_GPL(usb_choose_configuration); static int generic_probe(struct usb_device *udev) { diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index f829a1aad1c3..08d95e9d56c2 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1920,6 +1920,7 @@ free_interfaces: usb_autosuspend_device(dev); return 0; } +EXPORT_SYMBOL_GPL(usb_set_configuration); static LIST_HEAD(set_config_list); static DEFINE_SPINLOCK(set_config_lock); diff --git a/include/linux/usb.h b/include/linux/usb.h index c716da18c668..f434619f3975 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1668,6 +1668,10 @@ extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr); /* this request isn't really synchronous, but it belongs with the others */ extern int usb_driver_set_configuration(struct usb_device *udev, int config); +/* choose and set configuration for device */ +extern int usb_choose_configuration(struct usb_device *udev); +extern int usb_set_configuration(struct usb_device *dev, int configuration); + /* * timeouts, in milliseconds, used for sending/receiving control messages * they typically complete within a few frames (msec) after they're issued From 09c8c8fbf01a828e43cc06b89a060d86ef3efbc3 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Fri, 24 Jan 2014 09:25:05 -0700 Subject: [PATCH 0092/1375] staging/usbip: simplify usbip_dump_usb_device() udev->speed handling Change usbip_dump_usb_device() to use usb_speed_string() and remove the code that does switch on udev->speed and builds custom speed strings. Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/usbip_common.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 96552e3a1bfb..4a2aab16b10c 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -99,26 +99,8 @@ static void usbip_dump_usb_device(struct usb_device *udev) struct device *dev = &udev->dev; int i; - dev_dbg(dev, " devnum(%d) devpath(%s) ", - udev->devnum, udev->devpath); - - switch (udev->speed) { - case USB_SPEED_HIGH: - pr_debug("SPD_HIGH "); - break; - case USB_SPEED_FULL: - pr_debug("SPD_FULL "); - break; - case USB_SPEED_LOW: - pr_debug("SPD_LOW "); - break; - case USB_SPEED_UNKNOWN: - pr_debug("SPD_UNKNOWN "); - break; - default: - pr_debug("SPD_ERROR "); - break; - } + dev_dbg(dev, " devnum(%d) devpath(%s) usb speed(%s)", + udev->devnum, udev->devpath, usb_speed_string(udev->speed)); pr_debug("tt %p, ttport %d\n", udev->tt, udev->ttport); From d1fd43d7a63dea98730b2ac1af829cdb6b3b48c6 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Fri, 24 Jan 2014 11:34:13 -0700 Subject: [PATCH 0093/1375] staging/usbip: userspace to use linux header for usb_device_speed enum, missing speeds to speed_strings array Remove usb_device_speed enum define from usbip_common.h and change it to include linux/usb/ch9.h instead. Add speed strings for usb wireless and 3.0 to speed_strings array. Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/libsrc/usbip_common.c | 2 ++ drivers/staging/usbip/userspace/libsrc/usbip_common.h | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c index 66f03cc62ac6..6620d185d4bf 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c @@ -23,6 +23,8 @@ static const struct speed_string speed_strings[] = { { USB_SPEED_LOW, "1.5", "Low Speed(1.5Mbps)" }, { USB_SPEED_FULL, "12", "Full Speed(12Mbps)" }, { USB_SPEED_HIGH, "480", "High Speed(480Mbps)" }, + { USB_SPEED_WIRELESS, "53.3-480", "Wireless"}, + { USB_SPEED_SUPER, "5000", "Super Speed(5000Mbps)" }, { 0, NULL, NULL } }; diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h index 938ad1c36947..2cb81b3b35f7 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h @@ -14,6 +14,7 @@ #include #include +#include #ifndef USBIDS_FILE #define USBIDS_FILE "/usr/share/hwdata/usb.ids" @@ -76,13 +77,6 @@ extern int usbip_use_debug ; abort(); \ } while (0) -enum usb_device_speed { - USB_SPEED_UNKNOWN = 0, /* enumerating */ - USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ - USB_SPEED_HIGH, /* usb 2.0 */ - USB_SPEED_VARIABLE /* wireless (usb 2.5) */ -}; - /* FIXME: how to sync with drivers/usbip_common.h ? */ enum usbip_device_status { /* sdev is available. */ From e9e4433e6bbb9378fd6eb1c395de88ef8a512444 Mon Sep 17 00:00:00 2001 From: Salym Senyonga Date: Sat, 25 Jan 2014 12:54:39 +0300 Subject: [PATCH 0094/1375] Staging: ozwpan: Fix null dereference If net_dev is NULL memcpy() will Oops. Signed-off-by: Salym Senyonga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index cb060364dfe7..5d965cf06d59 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -668,8 +668,8 @@ void oz_binding_add(const char *net_dev) if (binding) { binding->ptype.type = __constant_htons(OZ_ETHERTYPE); binding->ptype.func = oz_pkt_recv; - memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); if (net_dev && *net_dev) { + memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); oz_dbg(ON, "Adding binding: %s\n", net_dev); binding->ptype.dev = dev_get_by_name(&init_net, net_dev); @@ -680,6 +680,7 @@ void oz_binding_add(const char *net_dev) } } else { oz_dbg(ON, "Binding to all netcards\n"); + memset(binding->name, 0, OZ_MAX_BINDING_LEN); binding->ptype.dev = NULL; } if (binding) { From a44755d88c1ac17549da59f97428f9204ba1bd5e Mon Sep 17 00:00:00 2001 From: Salym Senyonga Date: Sat, 25 Jan 2014 12:54:40 +0300 Subject: [PATCH 0095/1375] Staging: ozwpan: reduce indent levels in oz_binding_add(). When hit error then we can return immediately. This makes the code simpler and lets us remove some indenting. Signed-off-by: Salym Senyonga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 44 +++++++++++++++----------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 5d965cf06d59..c303ae144083 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -665,31 +665,29 @@ void oz_binding_add(const char *net_dev) struct oz_binding *binding; binding = kmalloc(sizeof(struct oz_binding), GFP_KERNEL); - if (binding) { - binding->ptype.type = __constant_htons(OZ_ETHERTYPE); - binding->ptype.func = oz_pkt_recv; - if (net_dev && *net_dev) { - memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); - oz_dbg(ON, "Adding binding: %s\n", net_dev); - binding->ptype.dev = - dev_get_by_name(&init_net, net_dev); - if (binding->ptype.dev == NULL) { - oz_dbg(ON, "Netdev %s not found\n", net_dev); - kfree(binding); - binding = NULL; - } - } else { - oz_dbg(ON, "Binding to all netcards\n"); - memset(binding->name, 0, OZ_MAX_BINDING_LEN); - binding->ptype.dev = NULL; - } - if (binding) { - dev_add_pack(&binding->ptype); - spin_lock_bh(&g_binding_lock); - list_add_tail(&binding->link, &g_binding); - spin_unlock_bh(&g_binding_lock); + if (!binding) + return; + + binding->ptype.type = __constant_htons(OZ_ETHERTYPE); + binding->ptype.func = oz_pkt_recv; + if (net_dev && *net_dev) { + memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); + oz_dbg(ON, "Adding binding: %s\n", net_dev); + binding->ptype.dev = dev_get_by_name(&init_net, net_dev); + if (binding->ptype.dev == NULL) { + oz_dbg(ON, "Netdev %s not found\n", net_dev); + kfree(binding); + return; } + } else { + oz_dbg(ON, "Binding to all netcards\n"); + memset(binding->name, 0, OZ_MAX_BINDING_LEN); + binding->ptype.dev = NULL; } + dev_add_pack(&binding->ptype); + spin_lock_bh(&g_binding_lock); + list_add_tail(&binding->link, &g_binding); + spin_unlock_bh(&g_binding_lock); } /* From e4b41af14d7dc683ecd84a10fed8ea38b94f0f28 Mon Sep 17 00:00:00 2001 From: Salym Senyonga Date: Sat, 25 Jan 2014 12:54:41 +0300 Subject: [PATCH 0096/1375] Staging: ozwpan: Change kmalloc() to kzalloc() changing to kzalloc lets us get rid of some lines. The other concern here is that some members of binding->ptype are still uninitialized at the end of the function. Signed-off-by: Salym Senyonga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index c303ae144083..e7138ed325dd 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -664,7 +664,7 @@ void oz_binding_add(const char *net_dev) { struct oz_binding *binding; - binding = kmalloc(sizeof(struct oz_binding), GFP_KERNEL); + binding = kzalloc(sizeof(struct oz_binding), GFP_KERNEL); if (!binding) return; @@ -679,10 +679,6 @@ void oz_binding_add(const char *net_dev) kfree(binding); return; } - } else { - oz_dbg(ON, "Binding to all netcards\n"); - memset(binding->name, 0, OZ_MAX_BINDING_LEN); - binding->ptype.dev = NULL; } dev_add_pack(&binding->ptype); spin_lock_bh(&g_binding_lock); From 54ab3e244d0b7e80120778503c697b9997cf673b Mon Sep 17 00:00:00 2001 From: Beomho Seo Date: Wed, 2 Apr 2014 09:16:00 +0100 Subject: [PATCH 0097/1375] iio: ak8975: Add device name This patch add device name. Signed-off-by: Beomho Seo Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index ff284e5afd95..039c3e85caf4 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -511,6 +511,7 @@ static int ak8975_probe(struct i2c_client *client, indio_dev->channels = ak8975_channels; indio_dev->num_channels = ARRAY_SIZE(ak8975_channels); indio_dev->info = &ak8975_info; + indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; err = iio_device_register(indio_dev); From ed10557fce856fc6fc79f98bc99c3b8a83fa0106 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Fri, 2 May 2014 10:34:00 +0100 Subject: [PATCH 0098/1375] iio: imu: mpu6050: Move config entry into IMU menu Signed-off-by: Manuel Stahl Signed-off-by: Jonathan Cameron --- drivers/iio/imu/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig index 663e88a1a3c1..2b0e45133e9d 100644 --- a/drivers/iio/imu/Kconfig +++ b/drivers/iio/imu/Kconfig @@ -25,6 +25,8 @@ config ADIS16480 Say yes here to build support for Analog Devices ADIS16375, ADIS16480, ADIS16485, ADIS16488 inertial sensors. +source "drivers/iio/imu/inv_mpu6050/Kconfig" + endmenu config IIO_ADIS_LIB @@ -38,5 +40,3 @@ config IIO_ADIS_LIB_BUFFER help A set of buffer helper functions for the Analog Devices ADIS* device family. - -source "drivers/iio/imu/inv_mpu6050/Kconfig" From 7da773e61831d677bfbe2bfcf10d39430f5a5bc2 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Fri, 2 May 2014 10:34:00 +0100 Subject: [PATCH 0099/1375] iio: imu: inv_mpu6050: Fix typo and formatting Signed-off-by: Manuel Stahl Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 38 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index bf7223b275ac..cb9f96b446a5 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -116,7 +116,7 @@ int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask) return result; if (en) { - /* Wait for output stablize */ + /* Wait for output stabilize */ msleep(INV_MPU6050_TEMP_UP_TIME); if (INV_MPU6050_BIT_PWR_GYRO_STBY == mask) { /* switch internal clock to PLL */ diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index f38395529a44..0ab382be1e64 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -126,35 +126,35 @@ struct inv_mpu6050_state { #define INV_MPU6050_REG_SAMPLE_RATE_DIV 0x19 #define INV_MPU6050_REG_CONFIG 0x1A #define INV_MPU6050_REG_GYRO_CONFIG 0x1B -#define INV_MPU6050_REG_ACCEL_CONFIG 0x1C +#define INV_MPU6050_REG_ACCEL_CONFIG 0x1C #define INV_MPU6050_REG_FIFO_EN 0x23 -#define INV_MPU6050_BIT_ACCEL_OUT 0x08 -#define INV_MPU6050_BITS_GYRO_OUT 0x70 +#define INV_MPU6050_BIT_ACCEL_OUT 0x08 +#define INV_MPU6050_BITS_GYRO_OUT 0x70 #define INV_MPU6050_REG_INT_ENABLE 0x38 -#define INV_MPU6050_BIT_DATA_RDY_EN 0x01 -#define INV_MPU6050_BIT_DMP_INT_EN 0x02 +#define INV_MPU6050_BIT_DATA_RDY_EN 0x01 +#define INV_MPU6050_BIT_DMP_INT_EN 0x02 #define INV_MPU6050_REG_RAW_ACCEL 0x3B #define INV_MPU6050_REG_TEMPERATURE 0x41 #define INV_MPU6050_REG_RAW_GYRO 0x43 #define INV_MPU6050_REG_USER_CTRL 0x6A -#define INV_MPU6050_BIT_FIFO_RST 0x04 -#define INV_MPU6050_BIT_DMP_RST 0x08 -#define INV_MPU6050_BIT_I2C_MST_EN 0x20 -#define INV_MPU6050_BIT_FIFO_EN 0x40 -#define INV_MPU6050_BIT_DMP_EN 0x80 +#define INV_MPU6050_BIT_FIFO_RST 0x04 +#define INV_MPU6050_BIT_DMP_RST 0x08 +#define INV_MPU6050_BIT_I2C_MST_EN 0x20 +#define INV_MPU6050_BIT_FIFO_EN 0x40 +#define INV_MPU6050_BIT_DMP_EN 0x80 #define INV_MPU6050_REG_PWR_MGMT_1 0x6B -#define INV_MPU6050_BIT_H_RESET 0x80 -#define INV_MPU6050_BIT_SLEEP 0x40 -#define INV_MPU6050_BIT_CLK_MASK 0x7 +#define INV_MPU6050_BIT_H_RESET 0x80 +#define INV_MPU6050_BIT_SLEEP 0x40 +#define INV_MPU6050_BIT_CLK_MASK 0x7 #define INV_MPU6050_REG_PWR_MGMT_2 0x6C -#define INV_MPU6050_BIT_PWR_ACCL_STBY 0x38 -#define INV_MPU6050_BIT_PWR_GYRO_STBY 0x07 +#define INV_MPU6050_BIT_PWR_ACCL_STBY 0x38 +#define INV_MPU6050_BIT_PWR_GYRO_STBY 0x07 #define INV_MPU6050_REG_FIFO_COUNT_H 0x72 #define INV_MPU6050_REG_FIFO_R_W 0x74 @@ -180,10 +180,10 @@ struct inv_mpu6050_state { /* init parameters */ #define INV_MPU6050_INIT_FIFO_RATE 50 -#define INV_MPU6050_TIME_STAMP_TOR 5 -#define INV_MPU6050_MAX_FIFO_RATE 1000 -#define INV_MPU6050_MIN_FIFO_RATE 4 -#define INV_MPU6050_ONE_K_HZ 1000 +#define INV_MPU6050_TIME_STAMP_TOR 5 +#define INV_MPU6050_MAX_FIFO_RATE 1000 +#define INV_MPU6050_MIN_FIFO_RATE 4 +#define INV_MPU6050_ONE_K_HZ 1000 /* scan element definition */ enum inv_mpu6050_scan { From f34b6cd3ee6c3cd80ce6ccfb1be203145718807f Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Sun, 9 Feb 2014 02:51:45 -0500 Subject: [PATCH 0100/1375] lustre/lov: avoid subobj's coh_parent race * during a file lov object initialization, we need protect the access and change of its subobj->coh_parent, since it could be another layout change race there, which makes an unreferenced lovsub obj in the site object hash table. * dump lovsub objects in the site if the lovsub device reference > 0 during its finalization phase. Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/6105 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1480 Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_object.c | 10 +++++++--- drivers/staging/lustre/lustre/lov/lovsub_dev.c | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index df8b5b5b7cf4..fe0b70a097aa 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -122,8 +122,8 @@ static struct cl_object *lov_sub_find(const struct lu_env *env, } static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, - struct cl_object *stripe, - struct lov_layout_raid0 *r0, int idx) + struct cl_object *stripe, struct lov_layout_raid0 *r0, + int idx) { struct cl_object_header *hdr; struct cl_object_header *subhdr; @@ -144,7 +144,6 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, hdr = cl_object_header(lov2cl(lov)); subhdr = cl_object_header(stripe); - parent = subhdr->coh_parent; oinfo = lov->lo_lsm->lsm_oinfo[idx]; CDEBUG(D_INODE, DFID"@%p[%d] -> "DFID"@%p: ostid: "DOSTID @@ -153,8 +152,12 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, PFID(&hdr->coh_lu.loh_fid), hdr, POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, oinfo->loi_ost_gen); + /* reuse ->coh_attr_guard to protect coh_parent change */ + spin_lock(&subhdr->coh_attr_guard); + parent = subhdr->coh_parent; if (parent == NULL) { subhdr->coh_parent = hdr; + spin_unlock(&subhdr->coh_attr_guard); subhdr->coh_nesting = hdr->coh_nesting + 1; lu_object_ref_add(&stripe->co_lu, "lov-parent", lov); r0->lo_sub[idx] = cl2lovsub(stripe); @@ -166,6 +169,7 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, struct lov_object *old_lov; unsigned int mask = D_INODE; + spin_unlock(&subhdr->coh_attr_guard); old_obj = lu_object_locate(&parent->coh_lu, &lov_device_type); LASSERT(old_obj != NULL); old_lov = cl2lov(lu2cl(old_obj)); diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 998ea1cbc7bb..926c35a25ceb 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -131,6 +131,10 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env, struct lovsub_device *lsd = lu2lovsub_dev(d); struct lu_device *next = cl2lu_dev(lsd->acid_next); + if (atomic_read(&d->ld_ref) && d->ld_site) { + LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL); + lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer); + } cl_device_fini(lu2cl_dev(d)); OBD_FREE_PTR(lsd); return next; From 7486bc06ab2c46d6957f0211d09bc549aaf9cc87 Mon Sep 17 00:00:00 2001 From: Swapnil Pimpale Date: Sun, 9 Feb 2014 02:51:46 -0500 Subject: [PATCH 0101/1375] lustre: Unsafe error handling around ll_splice_alias Callers of ll_splice_alias() should not assign the returned pointer to the dentry since it can be an err pointer. Fixed the above bug using a temporary dentry pointer. This temporary pointer is assigned to dentry only if ll_splice_alias has not returned an err pointer. Signed-off-by: Swapnil Pimpale Reviewed-on: http://review.whamcloud.com/7460 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3807 Reviewed-by: Fan Yong Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/namei.c | 9 ++++++--- drivers/staging/lustre/lustre/llite/statahead.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 1d03a6f8e4ad..8938d37feca7 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -462,9 +462,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, * Atoimc_open may passin hashed dentries for open. */ if (d_unhashed(*de)) { - *de = ll_splice_alias(inode, *de); - if (IS_ERR(*de)) - return PTR_ERR(*de); + struct dentry *alias; + + alias = ll_splice_alias(inode, *de); + if (IS_ERR(alias)) + return PTR_ERR(alias); + *de = alias; } if (!it_disposition(it, DISP_LOOKUP_NEG)) { diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 183b4157a7d8..ad61ad446f22 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -1585,12 +1585,15 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, ll_inode2fid(inode), &bits); if (rc == 1) { if ((*dentryp)->d_inode == NULL) { - *dentryp = ll_splice_alias(inode, + struct dentry *alias; + + alias = ll_splice_alias(inode, *dentryp); - if (IS_ERR(*dentryp)) { + if (IS_ERR(alias)) { ll_sai_unplug(sai, entry); - return PTR_ERR(*dentryp); + return PTR_ERR(alias); } + *dentryp = alias; } else if ((*dentryp)->d_inode != inode) { /* revalidate, but inode is recreated */ CDEBUG(D_READA, From 08a78a27e1693ca1cf5a11e41d7a374d7b14a2fd Mon Sep 17 00:00:00 2001 From: yang sheng Date: Sun, 9 Feb 2014 02:51:47 -0500 Subject: [PATCH 0102/1375] lustre: instantiate negative dentry In the atomic_open callback. We should instantiate negative dentry. Else will got sanity:183 failed. Signed-off-by: yang sheng Reviewed-on: http://review.whamcloud.com/8110 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3228 Reviewed-by: Peng Tao Reviewed-by: Lai Siyao Reviewed-by: James Simmons Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/namei.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 8938d37feca7..93c3744e09ff 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -468,6 +468,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, if (IS_ERR(alias)) return PTR_ERR(alias); *de = alias; + } else if (!it_disposition(it, DISP_LOOKUP_NEG) && + !it_disposition(it, DISP_OPEN_CREATE)) { + /* With DISP_OPEN_CREATE dentry will + instantiated in ll_create_it. */ + LASSERT((*de)->d_inode == NULL); + d_instantiate(*de, inode); } if (!it_disposition(it, DISP_LOOKUP_NEG)) { From e93a3082fc30dd648989f0986e482e0c914a502c Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Sun, 9 Feb 2014 02:51:48 -0500 Subject: [PATCH 0103/1375] lustre/xattr: separate ACL and XATTR caches This patch separates ACL and XATTR caches, so that when updating an ACL only LOOKUP lock is needed and when updating another XATTR only XATTR lock is needed. This patch also reverts XATTR cache support for setxattr because client performing REINT under even PR lock will deadlock if an active server operation (like unlink) attempts to cancel all locks, and setxattr has to wait for it (MDC max-in-flight is 1). This patch disables the r/o cache if the data is unreasonably large (larger than maximum single EA size). Signed-off-by: Andrew Perepechko Signed-off-by: Nathaniel Clark Reviewed-on: http://review.whamcloud.com/7208 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3669 Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 1 - .../staging/lustre/lustre/ldlm/ldlm_lock.c | 2 - .../lustre/lustre/llite/llite_internal.h | 7 -- drivers/staging/lustre/lustre/llite/xattr.c | 29 +++-- .../staging/lustre/lustre/llite/xattr_cache.c | 117 +++--------------- .../staging/lustre/lustre/mdc/mdc_internal.h | 2 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 9 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +- .../staging/lustre/lustre/mdc/mdc_request.c | 30 ++++- drivers/staging/lustre/lustre/ptlrpc/layout.c | 3 +- 10 files changed, 68 insertions(+), 134 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 05c77c0b2d75..4183a359f1f5 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1747,7 +1747,6 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \ OBD_MD_FLGENER | OBD_MD_FLRDEV | OBD_MD_FLGROUP) -#define OBD_MD_FLXATTRLOCKED OBD_MD_FLGETATTRLOCK #define OBD_MD_FLXATTRALL (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS) /* don't forget obdo_fid which is way down at the bottom so it can diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 692623beee12..0548aca45e8e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -145,8 +145,6 @@ char *ldlm_it2str(int it) return "getxattr"; case IT_LAYOUT: return "layout"; - case IT_SETXATTR: - return "setxattr"; default: CERROR("Unknown intent %d\n", it); return "UNKNOWN"; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 28669eafb396..bc17c2957943 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -296,13 +296,6 @@ int ll_xattr_cache_get(struct inode *inode, size_t size, __u64 valid); -int ll_xattr_cache_update(struct inode *inode, - const char *name, - const char *newval, - size_t size, - __u64 valid, - int flags); - /* * Locking to guarantee consistency of non-atomic updates to long long i_size, * consistency between file size and KMS. diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index af83580c6d48..b1ed4d9ea6be 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -183,17 +183,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, valid |= rce_ops2valid(rce->rce_ops); } #endif - if (sbi->ll_xattr_cache_enabled && - (rce == NULL || rce->rce_ops == RMT_LSETFACL)) { - rc = ll_xattr_cache_update(inode, name, pv, size, valid, flags); - } else { 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); @@ -292,6 +286,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, void *xdata; struct obd_capa *oc; struct rmtacl_ctl_entry *rce = NULL; + struct ll_inode_info *lli = ll_i2info(inode); CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -339,7 +334,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, */ if (xattr_type == XATTR_ACL_ACCESS_T && !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) { - struct ll_inode_info *lli = ll_i2info(inode); + struct posix_acl *acl; spin_lock(&lli->lli_lock); @@ -358,13 +353,27 @@ int ll_getxattr_common(struct inode *inode, const char *name, #endif do_getxattr: - if (sbi->ll_xattr_cache_enabled && (rce == NULL || - rce->rce_ops == RMT_LGETFACL || - rce->rce_ops == RMT_LSETFACL)) { + if (sbi->ll_xattr_cache_enabled && xattr_type != XATTR_ACL_ACCESS_T) { rc = ll_xattr_cache_get(inode, name, buffer, size, valid); + if (rc == -EAGAIN) + goto getxattr_nocache; if (rc < 0) GOTO(out_xattr, rc); + + /* Add "system.posix_acl_access" to the list */ + if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) { + if (size == 0) { + rc += sizeof(XATTR_NAME_ACL_ACCESS); + } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) { + memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS, + sizeof(XATTR_NAME_ACL_ACCESS)); + rc += sizeof(XATTR_NAME_ACL_ACCESS); + } else { + GOTO(out_xattr, rc = -ERANGE); + } + } } else { +getxattr_nocache: oc = ll_mdscapa_get(inode); rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, valid | (rce ? rce_ops2valid(rce->rce_ops) : 0), diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 3e3be1f13502..616d5bdf854d 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -98,13 +98,13 @@ static int ll_xattr_cache_find(struct list_head *cache, } /** - * This adds or updates an xattr. + * This adds an xattr. * * Add @xattr_name attr with @xattr_val value and @xattr_val_len length, - * if the attribute already exists, then update its value. * * \retval 0 success * \retval -ENOMEM if no memory could be allocated for the cached attr + * \retval -EPROTO if duplicate xattr is being added */ static int ll_xattr_cache_add(struct list_head *cache, const char *xattr_name, @@ -116,27 +116,8 @@ static int ll_xattr_cache_add(struct list_head *cache, if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) { - /* Found a cached EA, update it */ - - if (xattr_val_len != xattr->xe_vallen) { - char *val; - OBD_ALLOC(val, xattr_val_len); - if (val == NULL) { - CDEBUG(D_CACHE, - "failed to allocate %u bytes for xattr %s update\n", - xattr_val_len, xattr_name); - return -ENOMEM; - } - OBD_FREE(xattr->xe_value, xattr->xe_vallen); - xattr->xe_value = val; - xattr->xe_vallen = xattr_val_len; - } - memcpy(xattr->xe_value, xattr_val, xattr_val_len); - - CDEBUG(D_CACHE, "update: [%s]=%.*s\n", xattr_name, - xattr_val_len, xattr_val); - - return 0; + CDEBUG(D_CACHE, "duplicate xattr: [%s]\n", xattr_name); + return -EPROTO; } OBD_SLAB_ALLOC_PTR_GFP(xattr, xattr_kmem, __GFP_IO); @@ -292,7 +273,7 @@ int ll_xattr_cache_destroy(struct inode *inode) } /** - * Match or enqueue a PR or PW LDLM lock. + * Match or enqueue a PR lock. * * Find or request an LDLM lock with xattr data. * Since LDLM does not provide API for atomic match_or_enqueue, @@ -322,9 +303,7 @@ static int ll_xattr_find_get_lock(struct inode *inode, mutex_lock(&lli->lli_xattrs_enq_lock); /* Try matching first. */ - mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, - oit->it_op == IT_SETXATTR ? LCK_PW : - (LCK_PR | LCK_PW)); + mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, LCK_PR); if (mode != 0) { /* fake oit in mdc_revalidate_lock() manner */ oit->d.lustre.it_lock_handle = lockh.cookie; @@ -340,13 +319,7 @@ static int ll_xattr_find_get_lock(struct inode *inode, return PTR_ERR(op_data); } - op_data->op_valid = OBD_MD_FLXATTR | OBD_MD_FLXATTRLS | - OBD_MD_FLXATTRLOCKED; -#ifdef CONFIG_FS_POSIX_ACL - /* If working with ACLs, we would like to cache local ACLs */ - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - op_data->op_valid |= OBD_MD_FLRMTLGETFACL; -#endif + op_data->op_valid = OBD_MD_FLXATTR | OBD_MD_FLXATTRLS; rc = md_enqueue(exp, &einfo, oit, op_data, &lockh, NULL, 0, NULL, 0); ll_finish_md_op_data(op_data); @@ -409,7 +382,11 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) if (oit->d.lustre.it_status < 0) { CDEBUG(D_CACHE, "getxattr intent returned %d for fid "DFID"\n", oit->d.lustre.it_status, PFID(ll_inode2fid(inode))); - GOTO(out_destroy, rc = oit->d.lustre.it_status); + rc = oit->d.lustre.it_status; + /* xattr data is so large that we don't want to cache it */ + if (rc == -ERANGE) + rc = -EAGAIN; + GOTO(out_destroy, rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -447,6 +424,11 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) rc = -EPROTO; } else if (OBD_FAIL_CHECK(OBD_FAIL_LLITE_XATTR_ENOMEM)) { rc = -ENOMEM; + } else if (!strcmp(xdata, XATTR_NAME_ACL_ACCESS)) { + /* Filter out ACL ACCESS since it's cached separately */ + CDEBUG(D_CACHE, "not caching %s\n", + XATTR_NAME_ACL_ACCESS); + rc = 0; } else { rc = ll_xattr_cache_add(&lli->lli_xattrs, xdata, xval, *xsizes); @@ -467,8 +449,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) GOTO(out_maybe_drop, rc); out_maybe_drop: - /* drop lock on error or getxattr */ - if (rc != 0 || oit->it_op != IT_SETXATTR) + ll_intent_drop_lock(oit); if (rc != 0) @@ -553,65 +534,3 @@ out: return rc; } - - -/** - * Set/update an xattr value or remove xattr using the write-through cache. - * - * Set/update the xattr value (if @valid has OBD_MD_FLXATTR) of @name to @newval - * or - * remove the xattr @name (@valid has OBD_MD_FLXATTRRM set) from @inode. - * @flags is either XATTR_CREATE or XATTR_REPLACE as defined by setxattr(2) - * - * \retval 0 no error occured - * \retval -EPROTO network protocol error - * \retval -ENOMEM not enough memory for the cache - * \retval -ERANGE the buffer is not large enough - * \retval -ENODATA no such attr (in the removal case) - */ -int ll_xattr_cache_update(struct inode *inode, - const char *name, - const char *newval, - size_t size, - __u64 valid, - int flags) -{ - struct lookup_intent oit = { .it_op = IT_SETXATTR }; - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ptlrpc_request *req = NULL; - struct ll_inode_info *lli = ll_i2info(inode); - struct obd_capa *oc; - int rc; - - - - LASSERT(!!(valid & OBD_MD_FLXATTR) ^ !!(valid & OBD_MD_FLXATTRRM)); - - rc = ll_xattr_cache_refill(inode, &oit); - if (rc) - return rc; - - oc = ll_mdscapa_get(inode); - rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, - valid | OBD_MD_FLXATTRLOCKED, name, newval, - size, 0, flags, ll_i2suppgid(inode), &req); - capa_put(oc); - - if (rc) { - ll_intent_drop_lock(&oit); - GOTO(out, rc); - } - - if (valid & OBD_MD_FLXATTR) - rc = ll_xattr_cache_add(&lli->lli_xattrs, name, newval, size); - else if (valid & OBD_MD_FLXATTRRM) - rc = ll_xattr_cache_del(&lli->lli_xattrs, name); - - ll_intent_drop_lock(&oit); - GOTO(out, rc); -out: - up_write(&lli->lli_xattrs_list_rwsem); - ptlrpc_req_finished(req); - - return rc; -} diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 506982996c0e..fc21777b53c6 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -101,7 +101,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lustre_handle *lockh, void *lmm, int lmmsize, struct ptlrpc_request **req, __u64 extra_lock_flags); -int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, +int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, struct list_head *cancels, ldlm_mode_t mode, __u64 bits); /* mdc/mdc_request.c */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 8aa7c80c2002..288a41ec60c9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -378,13 +378,6 @@ mdc_intent_getxattr_pack(struct obd_export *exp, mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); - if (it->it_op == IT_SETXATTR) - /* If we want to upgrade to LCK_PW, let's cancel LCK_PR - * locks now. This avoids unnecessary ASTs. */ - count = mdc_resource_get_unused(exp, &op_data->op_fid1, - &cancels, LCK_PW, - MDS_INODELOCK_XATTR); - rc = ldlm_prep_enqueue_req(exp, req, &cancels, count); if (rc) { ptlrpc_request_free(req); @@ -842,7 +835,7 @@ resend: return -EOPNOTSUPP; req = mdc_intent_layout_pack(exp, it, op_data); lvb_type = LVB_T_LAYOUT; - } else if (it->it_op & (IT_GETXATTR | IT_SETXATTR)) { + } else if (it->it_op & IT_GETXATTR) { req = mdc_intent_getxattr_pack(exp, it, op_data); } else { LBUG(); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 9f3a345f34e0..1aea154e122b 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -66,7 +66,7 @@ static int mdc_reint(struct ptlrpc_request *request, /* Find and cancel locally locks matched by inode @bits & @mode in the resource * found by @fid. Found locks are added into @cancel list. Returns the amount of * locks added to @cancels list. */ -int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, +int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, struct list_head *cancels, ldlm_mode_t mode, __u64 bits) { diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 83013927e131..17c8e1486daa 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -355,10 +355,32 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, input_size); } - rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode); - if (rc) { - ptlrpc_request_free(req); - return rc; + /* Flush local XATTR locks to get rid of a possible cancel RPC */ + if (opcode == MDS_REINT && fid_is_sane(fid) && + exp->exp_connect_data.ocd_ibits_known & MDS_INODELOCK_XATTR) { + LIST_HEAD(cancels); + int count; + + /* Without that packing would fail */ + if (input_size == 0) + req_capsule_set_size(&req->rq_pill, &RMF_EADATA, + RCL_CLIENT, 0); + + count = mdc_resource_get_unused(exp, fid, + &cancels, LCK_EX, + MDS_INODELOCK_XATTR); + + rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); + if (rc) { + ptlrpc_request_free(req); + return rc; + } + } else { + rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode); + if (rc) { + ptlrpc_request_free(req); + return rc; + } } if (opcode == MDS_REINT) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 9b8f691cbeb7..41c12e00129f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -295,7 +295,8 @@ static const struct req_msg_field *mds_reint_setxattr_client[] = { &RMF_REC_REINT, &RMF_CAPA1, &RMF_NAME, - &RMF_EADATA + &RMF_EADATA, + &RMF_DLM_REQ }; static const struct req_msg_field *mdt_swap_layouts[] = { From 7345fb75e0ec4b2c84ece7ee4aabe8a0bdc06062 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Sun, 9 Feb 2014 02:51:49 -0500 Subject: [PATCH 0104/1375] lustre: don't leak llog handle in llog_cat_process_cb() An early return from llog_cat_process_cb() was leaking the llog handle. Fix this by not doing that. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/7847 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4054 Reviewed-by: Andreas Dilger Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Mike Pershin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index c0f3af725747..1d999310ec92 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -551,9 +551,8 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, if (rec->lrh_index < d->lpd_startcat) /* Skip processing of the logs until startcat */ - return 0; - - if (d->lpd_startidx > 0) { + rc = 0; + else if (d->lpd_startidx > 0) { struct llog_process_cat_data cd; cd.lpcd_first_idx = d->lpd_startidx; @@ -566,6 +565,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, rc = llog_process_or_fork(env, llh, d->lpd_cb, d->lpd_data, NULL, false); } + llog_handle_put(llh); return rc; From 38585ccc4627a9da381af9e912b756cfceb615a5 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 11 Feb 2014 02:52:05 -0700 Subject: [PATCH 0105/1375] staging/lustre/llite: fix O_TMPFILE/O_LOV_DELAY_CREATE conflict In kernel 3.11 O_TMPFILE was introduced, but the open flag value conflicts with the O_LOV_DELAY_CREATE flag 020000000 previously used by Lustre-aware applications. O_LOV_DELAY_CREATE allows applications to defer file layout and object creation from open time (the default) until it can instead be specified by the application using an ioctl. Instead of trying to find a non-conflicting O_LOV_DELAY_CREATE flag or define a Lustre-specific flag that isn't of use to most/any other filesystems, use (O_NOCTTY|FASYNC) as the new value. These flags are not meaningful for newly-created regular files and should be OK since O_LOV_DELAY_CREATE is only meaningful for new files. I looked into using O_ACCMODE/FMODE_WRITE_IOCTL, which allows calling ioctl() on the minimally-opened fd and is close to what is needed, but that doesn't allow specifying the actual read or write mode for the file, and fcntl(F_SETFL) doesn't allow O_RDONLY/O_WRONLY/O_RDWR to be set after the file is opened. Lustre-change: http://review.whamcloud.com/8312 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4209 Signed-off-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Peng Tao Cc: Al Viro Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/lustre/lustre_user.h | 12 +++++------ .../lustre/lustre/include/lustre_mdc.h | 11 ++++++++++ drivers/staging/lustre/lustre/llite/file.c | 21 ++++++++++--------- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 2 +- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index a74de59e2030..336360580910 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -265,13 +265,11 @@ struct ost_id { #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */ -/* Hopefully O_LOV_DELAY_CREATE does not conflict with standard O_xxx flags. - * Previously it was defined as 0100000000 and conflicts with FMODE_NONOTIFY - * which was added since kernel 2.6.36, so we redefine it as 020000000. - * To be compatible with old version's statically linked binary, finally we - * define it as (020000000 | 0100000000). - * */ -#define O_LOV_DELAY_CREATE 0120000000 +/* Define O_LOV_DELAY_CREATE to be a mask that is not useful for regular + * files, but are unlikely to be used in practice and are not harmful if + * used incorrectly. O_NOCTTY and FASYNC are only meaningful for character + * devices and are safe for use on new files (See LU-812, LU-4209). */ +#define O_LOV_DELAY_CREATE (O_NOCTTY | FASYNC) #define LL_FILE_IGNORE_LOCK 0x00000001 #define LL_FILE_GROUP_LOCKED 0x00000002 diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index c1e02702b931..468f36344a34 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -166,6 +166,17 @@ void it_clear_disposition(struct lookup_intent *it, int flag); void it_set_disposition(struct lookup_intent *it, int flag); int it_open_error(int phase, struct lookup_intent *it); +static inline bool cl_is_lov_delay_create(unsigned int flags) +{ + return (flags & O_LOV_DELAY_CREATE) == O_LOV_DELAY_CREATE; +} + +static inline void cl_lov_delay_create_clear(unsigned int *flags) +{ + if ((*flags & O_LOV_DELAY_CREATE) == O_LOV_DELAY_CREATE) + *flags &= ~O_LOV_DELAY_CREATE; +} + /** @} mdc */ #endif diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 19125d5c991a..abf5f4611abc 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -671,14 +671,13 @@ restart: ll_capa_open(inode); - if (!lli->lli_has_smd) { - if (file->f_flags & O_LOV_DELAY_CREATE || - !(file->f_mode & FMODE_WRITE)) { - CDEBUG(D_INODE, "object creation was delayed\n"); - GOTO(out_och_free, rc); - } + if (!lli->lli_has_smd && + (cl_is_lov_delay_create(file->f_flags) || + (file->f_mode & FMODE_WRITE) == 0)) { + CDEBUG(D_INODE, "object creation was delayed\n"); + GOTO(out_och_free, rc); } - file->f_flags &= ~O_LOV_DELAY_CREATE; + cl_lov_delay_create_clear(&file->f_flags); GOTO(out_och_free, rc); out_och_free: @@ -1381,23 +1380,25 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ccc_inode_lsm_put(inode, lsm); CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n", inode->i_ino); - return -EEXIST; + GOTO(out, rc = -EEXIST); } ll_inode_size_lock(inode); rc = ll_intent_file_open(file, lum, lum_size, &oit); if (rc) - GOTO(out, rc); + GOTO(out_unlock, rc); rc = oit.d.lustre.it_status; if (rc < 0) GOTO(out_req_free, rc); ll_release_openhandle(file->f_dentry, &oit); - out: +out_unlock: ll_inode_size_unlock(inode); ll_intent_release(&oit); ccc_inode_lsm_put(inode, lsm); +out: + cl_lov_delay_create_clear(&file->f_flags); return rc; out_req_free: ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 91f6876dac3f..5b9f37141512 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -197,7 +197,7 @@ static __u64 mds_pack_open_flags(__u64 flags, __u32 mode) if (flags & FMODE_EXEC) cr_flags |= MDS_FMODE_EXEC; #endif - if (flags & O_LOV_DELAY_CREATE) + if (cl_is_lov_delay_create(flags)) cr_flags |= MDS_OPEN_DELAY_CREATE; if (flags & O_NONBLOCK) From d249db9e5a82ed9ee49b6b7afb04878ba1fde5ea Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 7 Feb 2014 18:38:50 -0600 Subject: [PATCH 0106/1375] staging: r8188eu: Fix missing header Commit 2397c6e0927675d983b34a03401affdb64818d07 entitled "staging: r8188eu: Remove wrappers around vmalloc and vzalloc" and commit: 03bd6aea7ba610a1a19f840c373624b8b0adde0d entitled "staging: r8188eu: Remove wrappers around vfree" failed to add the header file needed to provide vzalloc and vfree. This problem was reported by the kbuild test robot. Reported-by: kbuild test robot Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 1 + drivers/staging/rtl8188eu/core/rtw_mp.c | 1 + drivers/staging/rtl8188eu/core/rtw_recv.c | 1 + drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 1 + drivers/staging/rtl8188eu/core/rtw_xmit.c | 1 + drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1 + drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 7 files changed, 7 insertions(+) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 2037be0acab8..927fc7225e00 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -31,6 +31,7 @@ #include #include #include +#include extern unsigned char MCS_rate_2R[16]; extern unsigned char MCS_rate_1R[16]; diff --git a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c index 9e97b5758368..99c06c45a1c0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mp.c +++ b/drivers/staging/rtl8188eu/core/rtw_mp.c @@ -23,6 +23,7 @@ #include "odm_precomp.h" #include "rtl8188e_hal.h" +#include u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz) { diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 8490d510f31e..ed308ff613df 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -28,6 +28,7 @@ #include #include #include +#include static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 6df96699ca43..e8a654d8db0c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -25,6 +25,7 @@ #include #include #include +#include static void _rtw_init_stainfo(struct sta_info *psta) { diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index aa77270cd8cf..2c0a40f40480 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -26,6 +26,7 @@ #include #include #include +#include static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 02040820f6f0..f3584dd832e2 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -35,6 +35,7 @@ #include #include +#include #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 8f58ef082102..b5c24298ed4c 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include From 8f1e98a3290797cc0322f69c0b609c54bea6b73b Mon Sep 17 00:00:00 2001 From: Surendra Patil Date: Sat, 8 Feb 2014 23:30:27 -0800 Subject: [PATCH 0107/1375] drivers:staging:rtl8821ae: Fixed few coding style erors and warnings Fixed multiple coding style errors and warnings wifi.h:1077: WARNING: please, no space before tabs wifi.h:762: WARNING: missing space after struct definition wifi.h:972: WARNING: please, no spaces at the start of a line wifi.h:1825: WARNING: Unnecessary space after function pointer name wifi.h:1826: ERROR: "foo * bar" should be "foo *bar" wifi.h:1099: WARNING: missing space after return type wifi.h:1320: ERROR: Macros with complex values should be enclosed in parenthesis wifi.h:1758: WARNING: Multiple spaces after return type wifi.h:1855: ERROR: code indent should use tabs where possible wifi.h:2303: ERROR: space prohibited after that open parenthesis '(' wifi.h:2408: ERROR: spaces required around that '=' (ctx:VxV) Signed-off-by: Surendra Patil Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/wifi.h | 446 ++++++++++++++++--------------- 1 file changed, 224 insertions(+), 222 deletions(-) diff --git a/drivers/staging/rtl8821ae/wifi.h b/drivers/staging/rtl8821ae/wifi.h index 76bef93ad70a..3b5b2e7fc35a 100644 --- a/drivers/staging/rtl8821ae/wifi.h +++ b/drivers/staging/rtl8821ae/wifi.h @@ -40,10 +40,10 @@ #define RF_CHANGE_BY_INIT 0 -#define RF_CHANGE_BY_IPS BIT(28) -#define RF_CHANGE_BY_PS BIT(29) -#define RF_CHANGE_BY_HW BIT(30) -#define RF_CHANGE_BY_SW BIT(31) +#define RF_CHANGE_BY_IPS BIT(28) +#define RF_CHANGE_BY_PS BIT(29) +#define RF_CHANGE_BY_HW BIT(30) +#define RF_CHANGE_BY_SW BIT(31) #define IQK_ADDA_REG_NUM 16 #define IQK_MAC_REG_NUM 4 @@ -69,7 +69,7 @@ #define QBSS_LOAD_SIZE 5 #define MAX_WMMELE_LENGTH 64 -#define TOTAL_CAM_ENTRY 32 +#define TOTAL_CAM_ENTRY 32 /*slot time for 11g. */ #define RTL_SLOT_TIME_9 9 @@ -77,27 +77,27 @@ /*related with tcp/ip. */ /*if_ehther.h*/ -#define ETH_P_PAE 0x888E /*Port Access Entity +#define ETH_P_PAE 0x888E /*Port Access Entity *(IEEE 802.1X) */ -#define ETH_P_IP 0x0800 /*Internet Protocol packet */ -#define ETH_P_ARP 0x0806 /*Address Resolution packet */ -#define SNAP_SIZE 6 +#define ETH_P_IP 0x0800 /*Internet Protocol packet */ +#define ETH_P_ARP 0x0806 /*Address Resolution packet */ +#define SNAP_SIZE 6 #define PROTOC_TYPE_SIZE 2 /*related with 802.11 frame*/ -#define MAC80211_3ADDR_LEN 24 -#define MAC80211_4ADDR_LEN 30 +#define MAC80211_3ADDR_LEN 24 +#define MAC80211_4ADDR_LEN 30 #define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max * channel number */ #define CHANNEL_MAX_NUMBER_2G 14 -#define CHANNEL_MAX_NUMBER_5G 54 /* Please refer to +#define CHANNEL_MAX_NUMBER_5G 54 /* Please refer to *"phy_GetChnlGroup8812A" and * "Hal_ReadTxPowerInfo8812A"*/ #define CHANNEL_MAX_NUMBER_5G_80M 7 #define CHANNEL_GROUP_MAX (3 + 9) /* ch1~3, ch4~9, ch10~14 * total three groups */ -#define MAX_PG_GROUP 13 +#define MAX_PG_GROUP 13 #define CHANNEL_GROUP_MAX_2G 3 #define CHANNEL_GROUP_IDX_5GL 3 #define CHANNEL_GROUP_IDX_5GM 6 @@ -119,7 +119,7 @@ #define MAX_CHNL_GROUP_5G 14 /* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */ -#define MAX_TX_QUEUE 9 +#define MAX_TX_QUEUE 9 #define TX_PWR_BY_RATE_NUM_BAND 2 #define TX_PWR_BY_RATE_NUM_RF 4 @@ -127,11 +127,11 @@ #define MAX_BASE_NUM_IN_PHY_REG_PG_24G 6 #define MAX_BASE_NUM_IN_PHY_REG_PG_5G 5 -#define DELTA_SWINGIDX_SIZE 30 -#define BAND_NUM 3 +#define DELTA_SWINGIDX_SIZE 30 +#define BAND_NUM 3 /*Now, it's just for 8192ee *not OK yet, keep it 0*/ -#define DMA_IS_64BIT 0 +#define DMA_IS_64BIT 0 #define RTL8192EE_SEG_NUM 1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */ struct txpower_info_2g { @@ -219,7 +219,7 @@ enum hardware_type { }; enum scan_operation_backup_opt { - SCAN_OPT_BACKUP_BAND0=0, + SCAN_OPT_BACKUP_BAND0 = 0, SCAN_OPT_BACKUP_BAND1, SCAN_OPT_RESTORE, SCAN_OPT_MAX @@ -645,9 +645,9 @@ enum wireless_mode { }; enum ratr_table_mode { - RATR_INX_WIRELESS_NGB = 0, // BGN 40 Mhz 2SS 1SS - RATR_INX_WIRELESS_NG = 1, // GN or N - RATR_INX_WIRELESS_NB = 2, // BGN 20 Mhz 2SS 1SS or BN + RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */ + RATR_INX_WIRELESS_NG = 1, /* GN or N */ + RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */ RATR_INX_WIRELESS_N = 3, RATR_INX_WIRELESS_GB = 4, RATR_INX_WIRELESS_G = 5, @@ -759,7 +759,7 @@ struct rtl_tid_data { struct rtl_ht_agg agg; }; -struct rssi_sta{ +struct rssi_sta { long undecorated_smoothed_pwdb; }; @@ -899,7 +899,7 @@ struct regd_pair_mapping { u16 reg_2ghz_ctl; }; -struct dynamic_primary_cca{ +struct dynamic_primary_cca { u8 pricca_flag; u8 intf_flag; u8 intf_type; @@ -939,14 +939,14 @@ enum p2p_ps_state { P2P_PS_ENABLE = 1, P2P_PS_SCAN = 2, P2P_PS_SCAN_DONE = 3, - P2P_PS_ALLSTASLEEP = 4, // for P2P GO + P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ }; enum p2p_ps_mode { P2P_PS_NONE = 0, P2P_PS_CTWINDOW = 1, P2P_PS_NOA = 2, - P2P_PS_MIX = 3, // CTWindow and NoA + P2P_PS_MIX = 3, /* CTWindow and NoA */ }; struct rtl_p2p_ps_info { @@ -969,7 +969,7 @@ struct rtl_p2p_ps_info { u32 noa_start_time[P2P_MAX_NOA_NUM]; }; - struct p2p_ps_offload_t { +struct p2p_ps_offload_t { u8 Offload_En:1; u8 role:1; /* 1: Owner, 0: Client */ u8 CTWindow_En:1; @@ -981,7 +981,7 @@ struct rtl_p2p_ps_info { }; #define IQK_MATRIX_REG_NUM 8 -#define IQK_MATRIX_SETTINGS_NUM (14+24+21) // Channels_2_4G_NUM + Channels_5G_20M_NUM + Channels_5G +#define IQK_MATRIX_SETTINGS_NUM (14+24+21) /* Channels_2_4G_NUM + Channels_5G_20M_NUM + Channels_5G */ struct iqk_matrix_regs { bool b_iqk_done; long value[1][IQK_MATRIX_REG_NUM]; @@ -1074,12 +1074,12 @@ struct rtl_phy { enum rt_polarity_ctl polarity_ctl; }; -#define RTL_AGG_STOP 0 +#define RTL_AGG_STOP 0 #define RTL_AGG_PROGRESS 1 -#define RTL_AGG_START 2 +#define RTL_AGG_START 2 #define RTL_AGG_OPERATIONAL 3 -#define RTL_RX_AGG_START 1 -#define RTL_RX_AGG_STOP 0 +#define RTL_RX_AGG_START 1 +#define RTL_RX_AGG_STOP 0 struct rtl_priv; struct rtl_io { @@ -1092,13 +1092,13 @@ struct rtl_io { /*PCI IO map */ unsigned long pci_base_addr; /*device I/O address */ - void (*write8_async) (struct rtl_priv * rtlpriv, u32 addr, u8 val); - void (*write16_async) (struct rtl_priv * rtlpriv, u32 addr, u16 val); - void (*write32_async) (struct rtl_priv * rtlpriv, u32 addr, u32 val); + void (*write8_async)(struct rtl_priv *rtlpriv, u32 addr, u8 val); + void (*write16_async)(struct rtl_priv *rtlpriv, u32 addr, u16 val); + void (*write32_async)(struct rtl_priv *rtlpriv, u32 addr, u32 val); - u8(*read8_sync) (struct rtl_priv * rtlpriv, u32 addr); - u16(*read16_sync) (struct rtl_priv * rtlpriv, u32 addr); - u32(*read32_sync) (struct rtl_priv * rtlpriv, u32 addr); + u8 (*read8_sync)(struct rtl_priv *rtlpriv, u32 addr); + u16 (*read16_sync)(struct rtl_priv *rtlpriv, u32 addr); + u32 (*read32_sync)(struct rtl_priv *rtlpriv, u32 addr); }; @@ -1317,9 +1317,9 @@ struct rtl_pstbl { }; -#define ASSOCIATE_ENTRY_NUM 32+1 +#define ASSOCIATE_ENTRY_NUM (32+1) -struct fast_ant_trainning{ +struct fast_ant_trainning { u8 bssid[6]; u8 antsel_rx_keep_0; u8 antsel_rx_keep_1; @@ -1427,19 +1427,19 @@ struct rtl_dm { char bb_swing_diff_5g; u8 delta_swing_table_idx_24gccka_p[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24gccka_n[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24gcckb_p[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24gccka_n[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24gcckb_p[DELTA_SWINGIDX_SIZE]; u8 delta_swing_table_idx_24gcckb_n[DELTA_SWINGIDX_SIZE]; u8 delta_swing_table_idx_24ga_p[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24ga_n[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24gb_p[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24gb_n[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_5ga_p[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_5ga_n[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_5gb_p[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_5gb_n[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24ga_p_8188e[DELTA_SWINGIDX_SIZE]; - u8 delta_swing_table_idx_24ga_n_8188e[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24ga_n[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24gb_p[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24gb_n[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_5ga_p[BAND_NUM][DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_5ga_n[BAND_NUM][DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_5gb_p[BAND_NUM][DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_5gb_n[BAND_NUM][DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24ga_p_8188e[DELTA_SWINGIDX_SIZE]; + u8 delta_swing_table_idx_24ga_n_8188e[DELTA_SWINGIDX_SIZE]; /* DMSP */ @@ -1451,7 +1451,7 @@ struct rtl_dm { struct fast_ant_trainning fat_table; u8 resp_tx_path; - u8 path_sel; + u8 path_sel; u32 patha_sum; u32 pathb_sum; u32 patha_cnt; @@ -1671,7 +1671,6 @@ struct rtl_stats { u8 rx_mimo_evm_dbm[4]; u16 cfo_short[4]; /* per-path's Cfo_short */ u16 cfo_tail[4]; - u8 rx_pwr[4]; /* per-path's pwdb */ u8 rx_snr[4]; /* per-path's SNR */ u8 bandwidth; @@ -1756,48 +1755,48 @@ struct proxim { void *proximity_priv; int (*proxim_rx)(struct ieee80211_hw *hw, struct rtl_stats *status, struct sk_buff *skb); - u8 (*proxim_get_var)(struct ieee80211_hw *hw, u8 type); + u8 (*proxim_get_var)(struct ieee80211_hw *hw, u8 type); }; struct rtl_hal_ops { - int (*init_sw_vars) (struct ieee80211_hw * hw); - void (*deinit_sw_vars) (struct ieee80211_hw * hw); - void (*read_eeprom_info) (struct ieee80211_hw * hw); - void (*interrupt_recognized) (struct ieee80211_hw * hw, - u32 * p_inta, u32 * p_intb); - int (*hw_init) (struct ieee80211_hw * hw); - void (*hw_disable) (struct ieee80211_hw * hw); - void (*hw_suspend) (struct ieee80211_hw * hw); - void (*hw_resume) (struct ieee80211_hw * hw); - void (*enable_interrupt) (struct ieee80211_hw * hw); - void (*disable_interrupt) (struct ieee80211_hw * hw); - int (*set_network_type) (struct ieee80211_hw * hw, - enum nl80211_iftype type); + int (*init_sw_vars)(struct ieee80211_hw *hw); + void (*deinit_sw_vars)(struct ieee80211_hw *hw); + void (*read_eeprom_info)(struct ieee80211_hw *hw); + void (*interrupt_recognized)(struct ieee80211_hw *hw, + u32 *p_inta, u32 *p_intb); + int (*hw_init)(struct ieee80211_hw *hw); + void (*hw_disable)(struct ieee80211_hw *hw); + void (*hw_suspend)(struct ieee80211_hw *hw); + void (*hw_resume)(struct ieee80211_hw *hw); + void (*enable_interrupt)(struct ieee80211_hw *hw); + void (*disable_interrupt)(struct ieee80211_hw *hw); + int (*set_network_type)(struct ieee80211_hw *hw, + enum nl80211_iftype type); void (*set_chk_bssid)(struct ieee80211_hw *hw, bool check_bssid); - void (*set_bw_mode) (struct ieee80211_hw * hw, - enum nl80211_channel_type ch_type); - u8(*switch_channel) (struct ieee80211_hw * hw); - void (*set_qos) (struct ieee80211_hw * hw, int aci); - void (*set_bcn_reg) (struct ieee80211_hw * hw); - void (*set_bcn_intv) (struct ieee80211_hw * hw); - void (*update_interrupt_mask) (struct ieee80211_hw * hw, - u32 add_msr, u32 rm_msr); - void (*get_hw_reg) (struct ieee80211_hw * hw, u8 variable, u8 * val); - void (*set_hw_reg) (struct ieee80211_hw * hw, u8 variable, u8 * val); - void (*update_rate_tbl) (struct ieee80211_hw * hw, - struct ieee80211_sta *sta, u8 rssi_level); - void (*pre_fill_tx_bd_desc) (struct ieee80211_hw *hw, u8 *tx_bd_desc, - u8 *desc, u8 queue_index, - struct sk_buff *skb, dma_addr_t addr); - u16 (*rx_desc_buff_remained_cnt) (struct ieee80211_hw *hw, - u8 queue_index); - void (*rx_check_dma_ok) (struct ieee80211_hw *hw, u8 *header_desc, - u8 queue_index); - void (*fill_tx_desc) (struct ieee80211_hw * hw, - struct ieee80211_hdr * hdr, - u8 * pdesc_tx, u8 * pbd_desc, - struct ieee80211_tx_info * info, + void (*set_bw_mode)(struct ieee80211_hw *hw, + enum nl80211_channel_type ch_type); + u8 (*switch_channel)(struct ieee80211_hw *hw); + void (*set_qos)(struct ieee80211_hw *hw, int aci); + void (*set_bcn_reg)(struct ieee80211_hw *hw); + void (*set_bcn_intv)(struct ieee80211_hw *hw); + void (*update_interrupt_mask)(struct ieee80211_hw *hw, + u32 add_msr, u32 rm_msr); + void (*get_hw_reg)(struct ieee80211_hw *hw, u8 variable, u8 *val); + void (*set_hw_reg)(struct ieee80211_hw *hw, u8 variable, u8 *val); + void (*update_rate_tbl)(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u8 rssi_level); + void (*pre_fill_tx_bd_desc)(struct ieee80211_hw *hw, u8 *tx_bd_desc, + u8 *desc, u8 queue_index, + struct sk_buff *skb, dma_addr_t addr); + u16 (*rx_desc_buff_remained_cnt)(struct ieee80211_hw *hw, + u8 queue_index); + void (*rx_check_dma_ok)(struct ieee80211_hw *hw, u8 *header_desc, + u8 queue_index); + void (*fill_tx_desc)(struct ieee80211_hw *hw, + struct ieee80211_hdr *hdr, + u8 *pdesc_tx, u8 *pbd_desc, + struct ieee80211_tx_info *info, /**/ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)) /**/ @@ -1805,74 +1804,77 @@ struct rtl_hal_ops { /**/ #endif /**/ - struct sk_buff * skb, u8 hw_queue, + struct sk_buff *skb, u8 hw_queue, struct rtl_tcb_desc *ptcb_desc); - void (*fill_tx_cmddesc) (struct ieee80211_hw * hw, u8 * pdesc, - bool b_firstseg, bool b_lastseg, - struct sk_buff * skb); - bool(*query_rx_desc) (struct ieee80211_hw * hw, - struct rtl_stats * status, - struct ieee80211_rx_status * rx_status, - u8 * pdesc, struct sk_buff * skb); - void (*set_channel_access) (struct ieee80211_hw * hw); - bool(*radio_onoff_checking) (struct ieee80211_hw * hw, u8 * valid); - void (*dm_watchdog) (struct ieee80211_hw * hw); - void (*scan_operation_backup) (struct ieee80211_hw * hw, u8 operation); - bool(*set_rf_power_state) (struct ieee80211_hw * hw, - enum rf_pwrstate rfpwr_state); - void (*led_control) (struct ieee80211_hw * hw, - enum led_ctl_mode ledaction); - void (*set_desc) (struct ieee80211_hw *hw, u8 * pdesc, bool istx, - u8 desc_name, u8 * val); - u32(*get_desc) (u8 * pdesc, bool istx, u8 desc_name); - bool (*is_tx_desc_closed) (struct ieee80211_hw *hw, - u8 hw_queue, u16 index); - void (*tx_polling) (struct ieee80211_hw * hw, u8 hw_queue); - void (*enable_hw_sec) (struct ieee80211_hw * hw); - void (*set_key) (struct ieee80211_hw * hw, u32 key_index, - u8 * p_macaddr, bool is_group, u8 enc_algo, - bool is_wepkey, bool clear_all); - void (*init_sw_leds) (struct ieee80211_hw * hw); - u32(*get_bbreg) (struct ieee80211_hw * hw, u32 regaddr, u32 bitmask); - void (*set_bbreg) (struct ieee80211_hw * hw, u32 regaddr, u32 bitmask, - u32 data); - u32(*get_rfreg) (struct ieee80211_hw * hw, enum radio_path rfpath, - u32 regaddr, u32 bitmask); - void (*set_rfreg) (struct ieee80211_hw * hw, enum radio_path rfpath, - u32 regaddr, u32 bitmask, u32 data); + void (*fill_tx_cmddesc)(struct ieee80211_hw *hw, u8 *pdesc, + bool b_firstseg, bool b_lastseg, + struct sk_buff *skb); + bool (*query_rx_desc)(struct ieee80211_hw *hw, + struct rtl_stats *status, + struct ieee80211_rx_status *rx_status, + u8 *pdesc, struct sk_buff *skb); + void (*set_channel_access)(struct ieee80211_hw *hw); + bool (*radio_onoff_checking)(struct ieee80211_hw *hw, u8 *valid); + void (*dm_watchdog)(struct ieee80211_hw *hw); + void (*scan_operation_backup)(struct ieee80211_hw *hw, u8 operation); + bool (*set_rf_power_state)(struct ieee80211_hw *hw, + enum rf_pwrstate rfpwr_state); + void (*led_control)(struct ieee80211_hw *hw, + enum led_ctl_mode ledaction); + void (*set_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx, + u8 desc_name, u8 *val); + u32 (*get_desc)(u8 *pdesc, bool istx, u8 desc_name); + bool (*is_tx_desc_closed)(struct ieee80211_hw *hw, + u8 hw_queue, u16 index); + void (*tx_polling)(struct ieee80211_hw *hw, u8 hw_queue); + void (*enable_hw_sec)(struct ieee80211_hw *hw); + void (*set_key)(struct ieee80211_hw *hw, u32 key_index, + u8 *p_macaddr, bool is_group, u8 enc_algo, + bool is_wepkey, bool clear_all); + void (*init_sw_leds)(struct ieee80211_hw *hw); + u32 (*get_bbreg)(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask); + void (*set_bbreg)(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask, + u32 data); + u32 (*get_rfreg)(struct ieee80211_hw *hw, enum radio_path rfpath, + u32 regaddr, u32 bitmask); + void (*set_rfreg)(struct ieee80211_hw *hw, enum radio_path rfpath, + u32 regaddr, u32 bitmask, u32 data); void (*allow_all_destaddr)(struct ieee80211_hw *hw, - bool allow_all_da, bool write_into_reg); - void (*linked_set_reg) (struct ieee80211_hw * hw); - void (*check_switch_to_dmdp) (struct ieee80211_hw * hw); - void (*dualmac_easy_concurrent) (struct ieee80211_hw *hw); - void (*dualmac_switch_to_dmdp) (struct ieee80211_hw *hw); - void (*c2h_command_handle) (struct ieee80211_hw *hw); - void (*bt_wifi_media_status_notify) (struct ieee80211_hw *hw, bool mstate); - void (*bt_turn_off_bt_coexist_before_enter_lps) (struct ieee80211_hw *hw); - void (*fill_h2c_cmd) (struct ieee80211_hw *hw, u8 element_id, - u32 cmd_len, u8 *p_cmdbuffer); - bool (*get_btc_status) (void); - u32 (*rx_command_packet_handler)(struct ieee80211_hw *hw, struct rtl_stats status, struct sk_buff *skb); + bool allow_all_da, bool write_into_reg); + void (*linked_set_reg)(struct ieee80211_hw *hw); + void (*check_switch_to_dmdp)(struct ieee80211_hw *hw); + void (*dualmac_easy_concurrent)(struct ieee80211_hw *hw); + void (*dualmac_switch_to_dmdp)(struct ieee80211_hw *hw); + void (*c2h_command_handle)(struct ieee80211_hw *hw); + void (*bt_wifi_media_status_notify)(struct ieee80211_hw *hw, + bool mstate); + void (*bt_turn_off_bt_coexist_before_enter_lps)(struct ieee80211_hw *hw); + void (*fill_h2c_cmd)(struct ieee80211_hw *hw, u8 element_id, + u32 cmd_len, u8 *p_cmdbuffer); + bool (*get_btc_status)(void); + u32 (*rx_command_packet_handler)(struct ieee80211_hw *hw, + struct rtl_stats status, + struct sk_buff *skb); }; struct rtl_intf_ops { /*com */ void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf); - int (*adapter_start) (struct ieee80211_hw * hw); - void (*adapter_stop) (struct ieee80211_hw * hw); + int (*adapter_start)(struct ieee80211_hw *hw); + void (*adapter_stop)(struct ieee80211_hw *hw); bool (*check_buddy_priv)(struct ieee80211_hw *hw, - struct rtl_priv **buddy_priv); + struct rtl_priv **buddy_priv); /**/ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - int (*adapter_tx) (struct ieee80211_hw * hw, struct sk_buff * skb, - struct rtl_tcb_desc *ptcb_desc); + int (*adapter_tx)(struct ieee80211_hw *hw, struct sk_buff *skb, + struct rtl_tcb_desc *ptcb_desc); #else /**/ - int (*adapter_tx) (struct ieee80211_hw *hw, - struct ieee80211_sta *sta, - struct sk_buff *skb, - struct rtl_tcb_desc *ptcb_desc); + int (*adapter_tx)(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct sk_buff *skb, + struct rtl_tcb_desc *ptcb_desc); /**/ #endif /**/ @@ -1881,22 +1883,22 @@ struct rtl_intf_ops { #else void (*flush)(struct ieee80211_hw *hw, bool drop); #endif - int (*reset_trx_ring) (struct ieee80211_hw * hw); + int (*reset_trx_ring)(struct ieee80211_hw *hw); /**/ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - bool (*waitq_insert) (struct ieee80211_hw *hw, struct sk_buff *skb); + bool (*waitq_insert)(struct ieee80211_hw *hw, struct sk_buff *skb); #else /**/ - bool (*waitq_insert) (struct ieee80211_hw *hw, - struct ieee80211_sta *sta, - struct sk_buff *skb); + bool (*waitq_insert)(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct sk_buff *skb); /**/ #endif /**/ /*pci */ - void (*disable_aspm) (struct ieee80211_hw * hw); - void (*enable_aspm) (struct ieee80211_hw * hw); + void (*disable_aspm)(struct ieee80211_hw *hw); + void (*enable_aspm)(struct ieee80211_hw *hw); /*usb */ }; @@ -2027,21 +2029,21 @@ struct rtl_btc_info { }; struct rtl_btc_ops { - void (*btc_init_variables) (struct rtl_priv *rtlpriv); - void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv); - void (*btc_init_hw_config) (struct rtl_priv *rtlpriv); - void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type); - void (*btc_scan_notify) (struct rtl_priv *rtlpriv, u8 scantype); - void (*btc_connect_notify) (struct rtl_priv *rtlpriv, u8 action); - void (*btc_mediastatus_notify) (struct rtl_priv *rtlpriv, - enum rt_media_status mstatus); - void (*btc_periodical) (struct rtl_priv *rtlpriv); - void (*btc_halt_notify) (void); - void (*btc_btinfo_notify) (struct rtl_priv *rtlpriv, - u8 * tmp_buf, u8 length); - bool (*btc_is_limited_dig) (struct rtl_priv *rtlpriv); - bool (*btc_is_disable_edca_turbo) (struct rtl_priv *rtlpriv); - bool (*btc_is_bt_disabled) (struct rtl_priv *rtlpriv); + void (*btc_init_variables)(struct rtl_priv *rtlpriv); + void (*btc_init_hal_vars)(struct rtl_priv *rtlpriv); + void (*btc_init_hw_config)(struct rtl_priv *rtlpriv); + void (*btc_ips_notify)(struct rtl_priv *rtlpriv, u8 type); + void (*btc_scan_notify)(struct rtl_priv *rtlpriv, u8 scantype); + void (*btc_connect_notify)(struct rtl_priv *rtlpriv, u8 action); + void (*btc_mediastatus_notify)(struct rtl_priv *rtlpriv, + enum rt_media_status mstatus); + void (*btc_periodical)(struct rtl_priv *rtlpriv); + void (*btc_halt_notify)(void); + void (*btc_btinfo_notify)(struct rtl_priv *rtlpriv, + u8 *tmp_buf, u8 length); + bool (*btc_is_limited_dig)(struct rtl_priv *rtlpriv); + bool (*btc_is_disable_edca_turbo)(struct rtl_priv *rtlpriv); + bool (*btc_is_bt_disabled)(struct rtl_priv *rtlpriv); }; struct rtl_bt_coexist { @@ -2120,57 +2122,57 @@ struct rtl_priv { #define rtl_hal(rtlpriv) (&((rtlpriv)->rtlhal)) #define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse)) #define rtl_psc(rtlpriv) (&((rtlpriv)->psc)) -#define rtl_sec(rtlpriv) (&((rtlpriv)->sec)) -#define rtl_dm(rtlpriv) (&((rtlpriv)->dm)) +#define rtl_sec(rtlpriv) (&((rtlpriv)->sec)) +#define rtl_dm(rtlpriv) (&((rtlpriv)->dm)) /*************************************** Bluetooth Co-existance Related ****************************************/ enum bt_ant_num { - ANT_X2 = 0, - ANT_X1 = 1, + ANT_X2 = 0, + ANT_X1 = 1, }; enum bt_co_type { - BT_2WIRE = 0, - BT_ISSC_3WIRE = 1, - BT_ACCEL = 2, - BT_CSR_BC4 = 3, - BT_CSR_BC8 = 4, - BT_RTL8756 = 5, - BT_RTL8723A = 6, - BT_RTL8821A = 7, - BT_RTL8723B = 8, - BT_RTL8192E = 9, - BT_RTL8812A = 11, + BT_2WIRE = 0, + BT_ISSC_3WIRE = 1, + BT_ACCEL = 2, + BT_CSR_BC4 = 3, + BT_CSR_BC8 = 4, + BT_RTL8756 = 5, + BT_RTL8723A = 6, + BT_RTL8821A = 7, + BT_RTL8723B = 8, + BT_RTL8192E = 9, + BT_RTL8812A = 11, }; -enum bt_total_ant_num{ +enum bt_total_ant_num { ANT_TOTAL_X2 = 0, ANT_TOTAL_X1 = 1 }; enum bt_cur_state { - BT_OFF = 0, - BT_ON = 1, + BT_OFF = 0, + BT_ON = 1, }; enum bt_service_type { - BT_SCO = 0, - BT_A2DP = 1, - BT_HID = 2, - BT_HID_IDLE = 3, - BT_SCAN = 4, - BT_IDLE = 5, - BT_OTHER_ACTION = 6, - BT_BUSY = 7, - BT_OTHERBUSY = 8, - BT_PAN = 9, + BT_SCO = 0, + BT_A2DP = 1, + BT_HID = 2, + BT_HID_IDLE = 3, + BT_SCAN = 4, + BT_IDLE = 5, + BT_OTHER_ACTION = 6, + BT_BUSY = 7, + BT_OTHERBUSY = 8, + BT_PAN = 9, }; enum bt_radio_shared { - BT_RADIO_SHARED = 0, - BT_RADIO_INDIVIDUAL = 1, + BT_RADIO_SHARED = 0, + BT_RADIO_INDIVIDUAL = 1, }; struct bt_coexist_info { @@ -2255,11 +2257,11 @@ struct bt_coexist_info { /* Write data to memory */ #define WRITEEF1BYTE(_ptr, _val) \ - (*((u8 *)(_ptr)))=EF1BYTE(_val) + ((*((u8 *)(_ptr))) = EF1BYTE(_val)) #define WRITEEF2BYTE(_ptr, _val) \ - (*((u16 *)(_ptr)))=EF2BYTE(_val) + ((*((u16 *)(_ptr))) = EF2BYTE(_val)) #define WRITEEF4BYTE(_ptr, _val) \ - (*((u32 *)(_ptr)))=EF4BYTE(_val) + ((*((u32 *)(_ptr))) = EF4BYTE(_val)) /*Example: BIT_LEN_MASK_32(0) => 0x00000000 @@ -2298,17 +2300,17 @@ Translate subfield (continuous bits in little-endian) of 4-byte value to host byte ordering.*/ #define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ ( \ - ( LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset) ) & \ + (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \ BIT_LEN_MASK_32(__bitlen) \ ) #define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ ( \ - ( LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset) ) & \ + (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \ BIT_LEN_MASK_16(__bitlen) \ ) #define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ ( \ - ( LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset) ) & \ + (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \ BIT_LEN_MASK_8(__bitlen) \ ) @@ -2318,17 +2320,17 @@ and return the result in 4-byte value in host byte ordering.*/ #define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ ( \ LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ - ( ~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) ) \ + (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \ ) #define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ ( \ LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \ - ( ~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) ) \ + (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \ ) #define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ ( \ LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \ - ( ~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) ) \ + (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ ) /*Description: @@ -2337,19 +2339,19 @@ Set subfield of little-endian 4-byte value to specified value. */ *((u32 *)(__pstart)) = EF4BYTE \ ( \ LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ - ( (((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset) )\ + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset))\ ); #define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \ *((u16 *)(__pstart)) = EF2BYTE \ ( \ LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ - ( (((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset) )\ + ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset))\ ); #define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ *((u8 *)(__pstart)) = EF1BYTE \ ( \ LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ - ( (((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset) ) \ + ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ ); #define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \ @@ -2359,18 +2361,18 @@ Set subfield of little-endian 4-byte value to specified value. */ mem access macro define end ****************************************/ -#define byte(x,n) ((x >> (8 * n)) & 0xff) +#define byte(x, n) ((x >> (8 * n)) & 0xff) #define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC) -#define RTL_WATCH_DOG_TIME 2000 +#define RTL_WATCH_DOG_TIME 2000 #define MSECS(t) msecs_to_jiffies(t) -#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) -#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) -#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) -#define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA) -#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) -#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) +#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) +#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) +#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) +#define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA) +#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) +#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) #define RT_RF_OFF_LEVL_ASPM BIT(0) /*PCI ASPM */ #define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /*PCI clock request */ @@ -2397,13 +2399,13 @@ Set subfield of little-endian 4-byte value to specified value. */ container_of(container_of(x, struct delayed_work, work), y, z) #define FILL_OCTET_STRING(_os,_octet,_len) \ - (_os).octet=(u8*)(_octet); \ - (_os).length=(_len); + (_os).octet = (u8 *)(_octet); \ + (_os).length = (_len); #define CP_MACADDR(des,src) \ - ((des)[0]=(src)[0],(des)[1]=(src)[1],\ - (des)[2]=(src)[2],(des)[3]=(src)[3],\ - (des)[4]=(src)[4],(des)[5]=(src)[5]) + ((des)[0] = (src)[0],(des)[1] = (src)[1],\ + (des)[2] = (src)[2],(des)[3] = (src)[3],\ + (des)[4] = (src)[4],(des)[5] = (src)[5]) static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr) { From d5d19999343b2d8f01890ffaabf1a6847a7e37a6 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 11 Feb 2014 13:31:32 +0100 Subject: [PATCH 0108/1375] staging: r8188eu: default to "y" in Kconfig Two Kconfig entries for this driver default to (uppercase) "Y". But in Kconfig (lowercase) "y" is a magic symbol. "Y" is an ordinary symbol. As "Y" is never set these Kconfig symbols will also not be set by default. So use "default y" here, as was clearly intended. Reported-by: Martin Walch Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/Kconfig b/drivers/staging/rtl8188eu/Kconfig index c9c548f17494..9a57d31ed248 100644 --- a/drivers/staging/rtl8188eu/Kconfig +++ b/drivers/staging/rtl8188eu/Kconfig @@ -12,7 +12,7 @@ if R8188EU config 88EU_AP_MODE bool "Realtek RTL8188EU AP mode" - default Y + default y ---help--- This option enables Access Point mode. Unless you know that your system will never be used as an AP, or the target system has limited memory, @@ -20,7 +20,7 @@ config 88EU_AP_MODE config 88EU_P2P bool "Realtek RTL8188EU Peer-to-peer mode" - default Y + default y ---help--- This option enables peer-to-peer mode for the r8188eu driver. Unless you know that peer-to-peer (P2P) mode will never be used, or the target system has From 8542373dccd2f5dd4dac0a552e2a22fc4402dbe9 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 9 Feb 2014 16:13:26 +0100 Subject: [PATCH 0109/1375] Staging: rtl8812ae: remove undefined Kconfig macros There are references to four undefined Kconfig macros in the code. Remove these as the checks for them will always evaluate to false. There are additional cleanups possible now, but I'll gladly leave those to people that are actually familiar with the code. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c index 9d9fa4d7575d..1152fc8683a0 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c @@ -732,17 +732,7 @@ bool exhalbtc_initlize_variables(struct rtl_priv *adapter) else btcoexist->binded = true; -#if ( defined(CONFIG_PCI_HCI)) - btcoexist->chip_interface = BTC_INTF_PCI; -#elif ( defined(CONFIG_USB_HCI)) - btcoexist->chip_interface = BTC_INTF_USB; -#elif ( defined(CONFIG_SDIO_HCI)) - btcoexist->chip_interface = BTC_INTF_SDIO; -#elif ( defined(CONFIG_GSPI_HCI)) - btcoexist->chip_interface = BTC_INTF_GSPI; -#else btcoexist->chip_interface = BTC_INTF_UNKNOWN; -#endif if (NULL == btcoexist->adapter) btcoexist->adapter = adapter; From 777e5d3ed55749e44febe3ae18dd9f0050bb8102 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Fri, 7 Feb 2014 23:02:27 -0600 Subject: [PATCH 0110/1375] Staging: comedi: fix memory leak in comedi_bond.c We allocate bdev and then krealloc the devs pointer in order to add bdev at the end of the devpriv->devs array list. But if for some reason this krealloc fails, we need to free bdev before returning an error otherwise this memory is leaked. Signed-off-by: Chase Southwood Acked-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 51a59e5b8ec5..406aedb5382e 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -254,6 +254,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) if (!devs) { dev_err(dev->class_dev, "Could not allocate memory. Out of memory?\n"); + kfree(bdev); return -ENOMEM; } devpriv->devs = devs; From a894c69be0566c9a7613468d833efd6303b79d95 Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Sat, 8 Feb 2014 11:59:40 +0900 Subject: [PATCH 0111/1375] staging: android: binder: use whitespace consistently Whitespace between #define keyword and BINDER_* constants are space in some point and tab in some point. Using space or tab is just writer's choice. But, let's use them more consistently. Signed-off-by: SeongJae Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index cbe345168067..c4c1ed6964e4 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -85,11 +85,11 @@ struct binder_version { #define BINDER_CURRENT_PROTOCOL_VERSION 7 #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) -#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) -#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) -#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) -#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) -#define BINDER_THREAD_EXIT _IOW('b', 8, __s32) +#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) +#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) +#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) +#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) +#define BINDER_THREAD_EXIT _IOW('b', 8, __s32) #define BINDER_VERSION _IOWR('b', 9, struct binder_version) /* From 51108985272c6e1d087bde0822d65921e625f268 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 10 Feb 2014 20:16:50 +0900 Subject: [PATCH 0112/1375] staging : ion : Fix some checkpatch warnings and an error Warning: - Unnecessary space after function pointer name - quoted string split across lines - fix alignment issues Error: - return is not a function, parentheses are not required Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 9 ++++----- drivers/staging/android/ion/ion_priv.h | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index b3395924f03e..14cb6c6cb106 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -56,8 +56,8 @@ struct ion_device { struct mutex buffer_lock; struct rw_semaphore lock; struct plist_head heaps; - long (*custom_ioctl) (struct ion_client *client, unsigned int cmd, - unsigned long arg); + long (*custom_ioctl)(struct ion_client *client, unsigned int cmd, + unsigned long arg); struct rb_root clients; struct dentry *debug_root; }; @@ -430,7 +430,7 @@ static bool ion_handle_validate(struct ion_client *client, struct ion_handle *handle) { WARN_ON(!mutex_is_locked(&client->lock)); - return (idr_find(&client->idr, handle->id) == handle); + return idr_find(&client->idr, handle->id) == handle; } static int ion_handle_add(struct ion_client *client, struct ion_handle *handle) @@ -1526,8 +1526,7 @@ void __init ion_reserve(struct ion_platform_data *data) data->heaps[i].align, MEMBLOCK_ALLOC_ANYWHERE); if (!paddr) { - pr_err("%s: error allocating memblock for " - "heap %d\n", + pr_err("%s: error allocating memblock for heap %d\n", __func__, i); continue; } diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index fc2e4fccf69d..0942a7fc82b4 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -101,19 +101,19 @@ void ion_buffer_destroy(struct ion_buffer *buffer); * map_dma and map_kernel return pointer on success, ERR_PTR on error. */ struct ion_heap_ops { - int (*allocate) (struct ion_heap *heap, - struct ion_buffer *buffer, unsigned long len, - unsigned long align, unsigned long flags); - void (*free) (struct ion_buffer *buffer); - int (*phys) (struct ion_heap *heap, struct ion_buffer *buffer, - ion_phys_addr_t *addr, size_t *len); - struct sg_table *(*map_dma) (struct ion_heap *heap, - struct ion_buffer *buffer); - void (*unmap_dma) (struct ion_heap *heap, struct ion_buffer *buffer); - void * (*map_kernel) (struct ion_heap *heap, struct ion_buffer *buffer); - void (*unmap_kernel) (struct ion_heap *heap, struct ion_buffer *buffer); - int (*map_user) (struct ion_heap *mapper, struct ion_buffer *buffer, - struct vm_area_struct *vma); + int (*allocate)(struct ion_heap *heap, + struct ion_buffer *buffer, unsigned long len, + unsigned long align, unsigned long flags); + void (*free)(struct ion_buffer *buffer); + int (*phys)(struct ion_heap *heap, struct ion_buffer *buffer, + ion_phys_addr_t *addr, size_t *len); + struct sg_table * (*map_dma)(struct ion_heap *heap, + struct ion_buffer *buffer); + void (*unmap_dma)(struct ion_heap *heap, struct ion_buffer *buffer); + void * (*map_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); + void (*unmap_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); + int (*map_user)(struct ion_heap *mapper, struct ion_buffer *buffer, + struct vm_area_struct *vma); }; /** From 0204c58e27fdc20275c0652b59a53547aa1ad136 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 10 Feb 2014 14:38:05 +0900 Subject: [PATCH 0113/1375] staging: android: timed_output: fix a checkpatch warning - WARNING: Multiple spaces after return type Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/timed_output.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/timed_output.h b/drivers/staging/android/timed_output.h index 905c7cc9588e..13d2ca51cbe8 100644 --- a/drivers/staging/android/timed_output.h +++ b/drivers/staging/android/timed_output.h @@ -20,10 +20,10 @@ struct timed_output_dev { const char *name; /* enable the output and set the timer */ - void (*enable)(struct timed_output_dev *sdev, int timeout); + void (*enable)(struct timed_output_dev *sdev, int timeout); /* returns the current number of milliseconds remaining on the timer */ - int (*get_time)(struct timed_output_dev *sdev); + int (*get_time)(struct timed_output_dev *sdev); /* private data */ struct device *dev; From 393f539c66a60f601effc22d9ad6c316360d791c Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 10 Feb 2014 14:36:48 +0900 Subject: [PATCH 0114/1375] staging : android : sync : fix a checkpatch warning - WARNING: missing space after return type Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 62e2255b1c1e..6ee8d69c5c6d 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -53,7 +53,7 @@ struct sync_timeline_ops { const char *driver_name; /* required */ - struct sync_pt *(*dup)(struct sync_pt *pt); + struct sync_pt * (*dup)(struct sync_pt *pt); /* required */ int (*has_signaled)(struct sync_pt *pt); From 0bb9a2ed7e678a22ec98c360aee20be7b7d97423 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 9 Feb 2014 14:10:44 +0530 Subject: [PATCH 0115/1375] staging: rtl8188eu: remove header file if_ether.h "if_ether.h" is included in three files but not being used, so remove "include/if_ether.h" header file and inclusion of this header file. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 1 - .../staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/if_ether.h | 111 ------------------ drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 - 4 files changed, 114 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/if_ether.h diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index ed308ff613df..a3cb6904455e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 17c94f4cc477..6e84f089c4e8 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8188eu/include/if_ether.h b/drivers/staging/rtl8188eu/include/if_ether.h deleted file mode 100644 index db157712a203..000000000000 --- a/drivers/staging/rtl8188eu/include/if_ether.h +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -#ifndef _LINUX_IF_ETHER_H -#define _LINUX_IF_ETHER_H - -/* - * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble - * and FCS/CRC (frame check sequence). - */ - -#define ETH_ALEN 6 /* Octets in one ethernet addr */ -#define ETH_HLEN 14 /* Total octets in header. */ -#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ -#define ETH_DATA_LEN 1500 /* Max. octets in payload */ -#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ - -/* - * These are the defined Ethernet Protocol ID's. - */ - -#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ -#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ -#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ -#define ETH_P_IP 0x0800 /* Internet Protocol packet */ -#define ETH_P_X25 0x0805 /* CCITT X.25 */ -#define ETH_P_ARP 0x0806 /* Address Resolution packet */ -#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet */ -#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ -#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP */ -#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ -#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ -#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ -#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ -#define ETH_P_LAT 0x6004 /* DEC LAT */ -#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ -#define ETH_P_CUST 0x6006 /* DEC Customer use */ -#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ -#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ -#define ETH_P_ATALK 0x809B /* Appletalk DDP */ -#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ -#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ -#define ETH_P_IPX 0x8137 /* IPX over DIX */ -#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ -#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ -#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ -#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ -#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport - * over Ethernet - */ - -/* - * Non DIX types. Won't clash for 1500 types. - */ - -#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ -#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ -#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ -#define ETH_P_802_2 0x0004 /* 802.2 frames */ -#define ETH_P_SNAP 0x0005 /* Internal only */ -#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ -#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ -#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ -#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ -#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ -#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ -#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ -#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ -#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ -#define ETH_P_ECONET 0x0018 /* Acorn Econet */ - -/* - * This is an Ethernet frame header. - */ - -struct ethhdr { - unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ - unsigned char h_source[ETH_ALEN]; /* source ether addr */ - unsigned short h_proto; /* packet type ID field */ -}; - -struct _vlan { - unsigned short h_vlan_TCI; /* Encap prio and VLAN ID */ - unsigned short h_vlan_encapsulated_proto; -}; - -#define get_vlan_id(pvlan) \ - ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff) -#define get_vlan_priority(pvlan) \ - ((ntohs((unsigned short)pvlan->h_vlan_TCI))>>13) -#define get_vlan_encap_proto(pvlan) \ - (ntohs((unsigned short)pvlan->h_vlan_encapsulated_proto)) - -#endif /* _LINUX_IF_ETHER_H */ diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 9005971084b7..24a84074a7e9 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include From aa6d5e4cde9cb530238807c487bd59c26ffcf8cb Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 9 Feb 2014 14:10:45 +0530 Subject: [PATCH 0116/1375] staging: rtl8188eu: remove header file ip.h "ip.h" is included in four files but not being used, so remove "include/ip.h" header file and inclusion of this header file. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 1 - drivers/staging/rtl8188eu/core/rtw_xmit.c | 1 - .../staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/ip.h | 126 ------------------ drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 - 5 files changed, 130 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/ip.h diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index a3cb6904455e..f665cbbdda45 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 2c0a40f40480..5a1d258a1fad 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 6e84f089c4e8..540c5adae82c 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8188eu/include/ip.h b/drivers/staging/rtl8188eu/include/ip.h deleted file mode 100644 index 9fdac6d42d17..000000000000 --- a/drivers/staging/rtl8188eu/include/ip.h +++ /dev/null @@ -1,126 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef _LINUX_IP_H -#define _LINUX_IP_H - -/* SOL_IP socket options */ - -#define IPTOS_TOS_MASK 0x1E -#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#define IPTOS_MINCOST 0x02 - -#define IPTOS_PREC_MASK 0xE0 -#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) -#define IPTOS_PREC_NETCONTROL 0xe0 -#define IPTOS_PREC_INTERNETCONTROL 0xc0 -#define IPTOS_PREC_CRITIC_ECP 0xa0 -#define IPTOS_PREC_FLASHOVERRIDE 0x80 -#define IPTOS_PREC_FLASH 0x60 -#define IPTOS_PREC_IMMEDIATE 0x40 -#define IPTOS_PREC_PRIORITY 0x20 -#define IPTOS_PREC_ROUTINE 0x00 - - -/* IP options */ -#define IPOPT_COPY 0x80 -#define IPOPT_CLASS_MASK 0x60 -#define IPOPT_NUMBER_MASK 0x1f - -#define IPOPT_COPIED(o) ((o)&IPOPT_COPY) -#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) -#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) - -#define IPOPT_CONTROL 0x00 -#define IPOPT_RESERVED1 0x20 -#define IPOPT_MEASUREMENT 0x40 -#define IPOPT_RESERVED2 0x60 - -#define IPOPT_END (0 | IPOPT_CONTROL) -#define IPOPT_NOOP (1 | IPOPT_CONTROL) -#define IPOPT_SEC (2 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_LSRR (3 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT) -#define IPOPT_RR (7 | IPOPT_CONTROL) -#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY) - -#define IPVERSION 4 -#define MAXTTL 255 -#define IPDEFTTL 64 -#define IPOPT_OPTVAL 0 -#define IPOPT_OLEN 1 -#define IPOPT_OFFSET 2 -#define IPOPT_MINOFF 4 -#define MAX_IPOPTLEN 40 -#define IPOPT_NOP IPOPT_NOOP -#define IPOPT_EOL IPOPT_END -#define IPOPT_TS IPOPT_TIMESTAMP - -#define IPOPT_TS_TSONLY 0 /* timestamps only */ -#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ -#define IPOPT_TS_PRESPEC 3 /* specified modules only */ - -struct ip_options { - __u32 faddr; /* Saved first hop address */ - unsigned char optlen; - unsigned char srr; - unsigned char rr; - unsigned char ts; - unsigned char is_setbyuser:1, /* Set by setsockopt? */ - is_data:1, /* Options in __data, rather than skb*/ - is_strictroute:1,/* Strict source route */ - srr_is_hit:1, /* Packet destn addr was ours */ - is_changed:1, /* IP checksum more not valid */ - rr_needaddr:1, /* Need to record addr of out dev*/ - ts_needtime:1, /* Need to record timestamp */ - ts_needaddr:1; /* Need to record addr of out dev */ - unsigned char router_alert; - unsigned char __pad1; - unsigned char __pad2; - unsigned char __data[0]; -}; - -#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) - -struct iphdr { -#if defined(__LITTLE_ENDIAN_BITFIELD) - __u8 ihl:4, - version:4; -#elif defined(__BIG_ENDIAN_BITFIELD) - __u8 version:4, - ihl:4; -#endif - __u8 tos; - __u16 tot_len; - __u16 id; - __u16 frag_off; - __u8 ttl; - __u8 protocol; - __u16 check; - __u32 saddr; - __u32 daddr; - /*The options start here. */ -}; - -#endif /* _LINUX_IP_H */ diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 24a84074a7e9..8097903f3b68 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include From 161737a619961b1a5bfe9f32704245b686d30792 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Mon, 10 Feb 2014 22:36:23 +0400 Subject: [PATCH 0117/1375] staging: slicoss: Fix possible reuse of freed memory in timer function Do not call kfree() till timer function is finished. [This was found using grep. Compiled tested only] Signed-off-by: Kirill Tkhai CC: Joe Perches CC: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 1426ca49bfe8..e0de4979e1cb 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2970,7 +2970,7 @@ static void slic_card_cleanup(struct sliccard *card) { if (card->loadtimerset) { card->loadtimerset = 0; - del_timer(&card->loadtimer); + del_timer_sync(&card->loadtimer); } slic_debug_card_destroy(card); From 510fa4085277379436752d9cb20b2eb4135c34a0 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 10 Feb 2014 16:37:56 -0800 Subject: [PATCH 0118/1375] staging: slicoss: Add MAINTAINERS entry, break README into TODO & README Adding a MAINTAINERS entry with content from the README. Move the TODO items from the README to a separate TODO file. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 +++++ drivers/staging/slicoss/README | 40 ---------------------------------- drivers/staging/slicoss/TODO | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 drivers/staging/slicoss/TODO diff --git a/MAINTAINERS b/MAINTAINERS index b2cf5cfb4d29..2af6445fd9e7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8311,6 +8311,12 @@ M: Teddy Wang S: Odd Fixes F: drivers/staging/sm7xxfb/ +STAGING - SLICOSS +M: Lior Dotan +M: Christopher Harrer +S: Odd Fixes +F: drivers/staging/slicoss/ + STAGING - SOFTLOGIC 6x10 MPEG CODEC M: Ismael Luceno S: Supported diff --git a/drivers/staging/slicoss/README b/drivers/staging/slicoss/README index 53052c4e78ae..4fa50e73ce86 100644 --- a/drivers/staging/slicoss/README +++ b/drivers/staging/slicoss/README @@ -5,43 +5,3 @@ This driver is supposed to support: Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber The driver was actually tested on Oasis and Kalahari cards. - -TODO: - - move firmware loading to request_firmware() - - remove direct memory access of structures - - any remaining sparse and checkpatch.pl warnings - - - use net_device_ops - - use dev->stats rather than adapter->stats - - don't cast netdev_priv it is already void - - GET RID OF MACROS - - work on all architectures - - without CONFIG_X86_64 confusion - - do 64 bit correctly - - don't depend on order of union - - get rid of ASSERT(), use BUG() instead but only where necessary - looks like most aren't really useful - - no new SIOCDEVPRIVATE ioctl allowed - - don't use module_param for configuring interrupt mitigation - use ethtool instead - - reorder code to elminate use of forward declarations - - don't keep private linked list of drivers. - - remove all the gratiutous debug infrastructure - - use PCI_DEVICE() - - do ethtool correctly using ethtool_ops - - NAPI? - - wasted overhead of extra stats - - 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 - - -Please send patches to: - Greg Kroah-Hartman -and Cc: Lior Dotan and Christopher Harrer - as well as they are also able to test out any -changes. diff --git a/drivers/staging/slicoss/TODO b/drivers/staging/slicoss/TODO new file mode 100644 index 000000000000..62ff1008b1ee --- /dev/null +++ b/drivers/staging/slicoss/TODO @@ -0,0 +1,38 @@ +TODO: + - move firmware loading to request_firmware() + - remove direct memory access of structures + - any remaining sparse and checkpatch.pl warnings + + - use net_device_ops + - use dev->stats rather than adapter->stats + - don't cast netdev_priv it is already void + - GET RID OF MACROS + - work on all architectures + - without CONFIG_X86_64 confusion + - do 64 bit correctly + - don't depend on order of union + - get rid of ASSERT(), use BUG() instead but only where necessary + looks like most aren't really useful + - no new SIOCDEVPRIVATE ioctl allowed + - don't use module_param for configuring interrupt mitigation + use ethtool instead + - reorder code to elminate use of forward declarations + - don't keep private linked list of drivers. + - remove all the gratiutous debug infrastructure + - use PCI_DEVICE() + - do ethtool correctly using ethtool_ops + - NAPI? + - wasted overhead of extra stats + - 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 + +Please send patches to: + Greg Kroah-Hartman +and Cc: Lior Dotan and Christopher Harrer + as well as they are also able to test out any +changes. From f42f52aaf922e5bae7775dd2c3b3954719ee5f08 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 9 Feb 2014 15:15:54 -0600 Subject: [PATCH 0119/1375] staging: r8188eu: Replace wrapper around _rtw_memcmp() This wrapper is replaced with a simple memcmp(). As the wrapper inverts the logic of memcmp(), care needed to be taken. This patch also adds one include of vmalloc.h that was missed in a previous patch. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 16 ++-- .../staging/rtl8188eu/core/rtw_ieee80211.c | 42 +++++----- .../staging/rtl8188eu/core/rtw_ioctl_set.c | 4 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 20 ++--- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 76 ++++++++++--------- drivers/staging/rtl8188eu/core/rtw_p2p.c | 20 ++--- drivers/staging/rtl8188eu/core/rtw_recv.c | 48 ++++++------ drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 10 +-- .../staging/rtl8188eu/core/rtw_wlan_util.c | 42 +++++----- drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 +- .../staging/rtl8188eu/hal/HalPhyRf_8188e.c | 4 +- drivers/staging/rtl8188eu/hal/odm.c | 4 +- drivers/staging/rtl8188eu/hal/odm_interface.c | 33 -------- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 1 + drivers/staging/rtl8188eu/hal/rtl8188e_mp.c | 4 +- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 4 +- .../staging/rtl8188eu/include/osdep_service.h | 1 - .../staging/rtl8188eu/os_dep/osdep_service.c | 10 --- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 4 +- 19 files changed, 154 insertions(+), 193 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 8ebe6bc40022..fe5ec8eba7f6 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -980,7 +980,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && (_rtw_memcmp(p+2, OUI1, 4))) { + if ((p) && (!memcmp(p+2, OUI1, 4))) { if (rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; @@ -1005,7 +1005,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && _rtw_memcmp(p+2, WMM_PARA_IE, 6)) { + if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { pmlmepriv->qospriv.qos_option = 1; *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ @@ -1150,7 +1150,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); - if (_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { added = true; DBG_88E("%s, sta has been added\n", __func__); @@ -1211,7 +1211,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); - if (_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { paclnode->valid = false; @@ -1351,13 +1351,13 @@ static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) { DBG_88E("%s\n", __func__); - if (_rtw_memcmp(RTW_WPA_OUI, oui, 4)) + if (!memcmp(RTW_WPA_OUI, oui, 4)) update_bcn_wpa_ie(padapter); - else if (_rtw_memcmp(WMM_OUI, oui, 4)) + else if (!memcmp(WMM_OUI, oui, 4)) update_bcn_wmm_ie(padapter); - else if (_rtw_memcmp(WPS_OUI, oui, 4)) + else if (!memcmp(WPS_OUI, oui, 4)) update_bcn_wps_ie(padapter); - else if (_rtw_memcmp(P2P_OUI, oui, 4)) + else if (!memcmp(P2P_OUI, oui, 4)) update_bcn_p2p_ie(padapter); else DBG_88E("unknown OUI type!\n"); diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index e6f98fb8f113..002195acb5d5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -273,7 +273,7 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u cnt = 0; while (cnt < in_len) { - if (eid == in_ie[cnt] && (!oui || _rtw_memcmp(&in_ie[cnt+2], oui, oui_len))) { + if (eid == in_ie[cnt] && (!oui || !memcmp(&in_ie[cnt+2], oui, oui_len))) { target_ie = &in_ie[cnt]; if (ie) @@ -463,7 +463,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) if (pbuf) { /* check if oui matches... */ - if (_rtw_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == false) + if (!memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type)) == false) goto check_next_ie; /* check version... */ @@ -497,15 +497,15 @@ unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) int rtw_get_wpa_cipher_suite(u8 *s) { - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == true) return WPA_CIPHER_NONE; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == true) return WPA_CIPHER_WEP40; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == true) return WPA_CIPHER_TKIP; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == true) return WPA_CIPHER_CCMP; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == true) return WPA_CIPHER_WEP104; return 0; @@ -513,15 +513,15 @@ int rtw_get_wpa_cipher_suite(u8 *s) int rtw_get_wpa2_cipher_suite(u8 *s) { - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == true) return WPA_CIPHER_NONE; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == true) return WPA_CIPHER_WEP40; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == true) return WPA_CIPHER_TKIP; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == true) return WPA_CIPHER_CCMP; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == true) return WPA_CIPHER_WEP104; return 0; @@ -542,7 +542,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || - (_rtw_memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != true)) + (!memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != true)) return _FAIL; pos = wpa_ie; @@ -587,7 +587,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis if (is_8021x) { if (left >= 6) { pos += 2; - if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) { + if (!memcmp(pos, SUITE_1X, 4) == 1) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); *is_8021x = 1; } @@ -657,7 +657,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi if (is_8021x) { if (left >= 6) { pos += 2; - if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) { + if (!memcmp(pos, SUITE_1X, 4) == 1) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); *is_8021x = 1; } @@ -683,7 +683,7 @@ _func_enter_; while (cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2)); @@ -741,7 +741,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4))) { + if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { *wps_ielen = ie_ptr[1]+2; match = true; } @@ -774,7 +774,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], wps_oui, 4))) { + if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { wpsie_ptr = &in_ie[cnt]; if (wps_ie) @@ -813,7 +813,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at *len_attr = 0; if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || - (_rtw_memcmp(wps_ie + 2, wps_oui , 4) != true)) + (!memcmp(wps_ie + 2, wps_oui , 4) != true)) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ @@ -1223,7 +1223,7 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) dump_stack(); return NULL; } - if ((eid == _VENDOR_SPECIFIC_IE_) && (_rtw_memcmp(&in_ie[cnt+2], p2p_oui, 4) == true)) { + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&in_ie[cnt+2], p2p_oui, 4) == true)) { p2p_ie_ptr = in_ie + cnt; if (p2p_ie != NULL) @@ -1258,7 +1258,7 @@ u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_att *len_attr = 0; if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || - (_rtw_memcmp(p2p_ie + 2, p2p_oui , 4) != true)) + (!memcmp(p2p_ie + 2, p2p_oui , 4) != true)) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index e25b39b97d9e..125ba4c70bf2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -205,7 +205,7 @@ _func_enter_; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); - if (_rtw_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { + if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { @@ -296,7 +296,7 @@ _func_enter_; ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && - (_rtw_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { + (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is the same ssid, fw_state = 0x%08x\n", diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 927fc7225e00..4f482e23e785 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -277,7 +277,7 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; _func_enter_; - if (_rtw_memcmp(zero_addr, addr, ETH_ALEN)) { + if (!memcmp(zero_addr, addr, ETH_ALEN)) { pnetwork = NULL; goto exit; } @@ -286,7 +286,7 @@ _func_enter_; while (plist != phead) { pnetwork = LIST_CONTAINOR(plist, struct wlan_network , list); - if (_rtw_memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) + if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) break; plist = get_next(plist); } @@ -458,7 +458,7 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { return (a->Ssid.SsidLength == b->Ssid.SsidLength) && - _rtw_memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); + !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); } int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) @@ -477,8 +477,8 @@ _func_enter_; _func_exit_; return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && - ((_rtw_memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && - ((_rtw_memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && + ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && + ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && ((s_cap & WLAN_CAPABILITY_BSS) == @@ -756,7 +756,7 @@ _func_enter_; /* update IBSS_network 's timestamp */ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { - if (_rtw_memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); @@ -1218,7 +1218,7 @@ _func_enter_; else RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - the_same_macaddr = _rtw_memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); + the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { @@ -1687,14 +1687,14 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv /* check bssid, if needed */ if (pmlmepriv->assoc_by_bssid) { - if (!_rtw_memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) + if (memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) goto exit; } /* check ssid, if needed */ if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength || - _rtw_memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false) + !memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false) goto exit; } @@ -1964,7 +1964,7 @@ static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) do { if ((psecuritypriv->PMKIDList[i].bUsed) && - (_rtw_memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN) == true)) { + (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN) == true)) { break; } else { i++; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 6f7e415ecb6c..ce9658617f2e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -421,8 +421,8 @@ static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptabl if (ptable->func) { /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - !_rtw_memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) return; ptable->func(padapter, precv_frame); } @@ -449,8 +449,8 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) } /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - !_rtw_memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) return; ptable = mlme_sta_tbl; @@ -596,7 +596,7 @@ _continue: if (is_valid_p2p_probereq) goto _issue_probersp; - if ((ielen != 0 && !_rtw_memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || + if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) return _SUCCESS; @@ -620,7 +620,7 @@ unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) #ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { if (pwdinfo->tx_prov_disc_info.benable) { - if (_rtw_memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + if (!memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { pwdinfo->tx_prov_disc_info.benable = false; issue_p2p_provision_request(padapter, @@ -638,7 +638,7 @@ unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { if (pwdinfo->nego_req_info.benable) { DBG_88E("[%s] P2P State is GONEGO ING!\n", __func__); - if (_rtw_memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + if (!memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { pwdinfo->nego_req_info.benable = false; issue_p2p_GO_request(padapter, pwdinfo->nego_req_info.peerDevAddr); } @@ -646,7 +646,7 @@ unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { if (pwdinfo->invitereq_info.benable) { DBG_88E("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__); - if (_rtw_memcmp(pwdinfo->invitereq_info.peer_macaddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + if (!memcmp(pwdinfo->invitereq_info.peer_macaddr, GetAddr2Ptr(pframe), ETH_ALEN)) { pwdinfo->invitereq_info.benable = false; issue_p2p_invitation_request(padapter, pwdinfo->invitereq_info.peer_macaddr); } @@ -681,7 +681,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } - if (_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { + if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), 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)); @@ -878,7 +878,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) goto auth_fail; } - if (_rtw_memcmp((void *)(p + 2), pstat->chg_txt, 128)) { + 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... */ @@ -939,7 +939,7 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) @@ -1097,7 +1097,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) status = _STATS_FAILURE_; } else { /* check if ssid match */ - if (!_rtw_memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) status = _STATS_FAILURE_; if (ie_len != cur->Ssid.SsidLength) @@ -1270,7 +1270,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) for (;;) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p != NULL) { - if (_rtw_memcmp(p+2, WMM_IE, 6)) { + if (!memcmp(p+2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; pstat->qos_option = 1; @@ -1486,7 +1486,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) @@ -1524,7 +1524,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if (_rtw_memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ + if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ WMM_param_handler(padapter, pIE); break; case _HT_CAPABILITY_IE_: /* HT caps */ @@ -1572,7 +1572,8 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) #endif /* CONFIG_88EU_P2P */ /* check A3 */ - if (!(_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + if (memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), + ETH_ALEN)) return _SUCCESS; #ifdef CONFIG_88EU_P2P @@ -1635,7 +1636,8 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) #endif /* CONFIG_88EU_P2P */ /* check A3 */ - if (!(_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + if (memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), + ETH_ALEN)) return _SUCCESS; #ifdef CONFIG_88EU_P2P @@ -1752,7 +1754,8 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra u8 *pframe = precv_frame->u.hdr.rx_data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), + ETH_ALEN))/* for if1, sta/ap mode */ return _SUCCESS; DBG_88E("%s\n", __func__); @@ -2280,7 +2283,7 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame /* Commented by Kurt 20120113 */ /* If some device wants to do p2p handshake without sending prov_disc_req */ /* We have to get peer_req_cm from here. */ - if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { + if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { if (wps_devicepassword_id == WPS_DPID_USER_SPEC) memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) @@ -2825,7 +2828,8 @@ void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) /* Channel Number */ p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch; /* operating channel number */ - if (_rtw_memcmp(myid(&padapter->eeprompriv), pwdinfo->invitereq_info.go_bssid, ETH_ALEN)) { + if (!memcmp(myid(&padapter->eeprompriv), + pwdinfo->invitereq_info.go_bssid, ETH_ALEN)) { /* P2P Group BSSID */ /* Type: */ p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; @@ -3260,7 +3264,7 @@ static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profil for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { DBG_88E("[%s] profileinfo_mac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, profileinfo->peermac[0], profileinfo->peermac[1], profileinfo->peermac[2], profileinfo->peermac[3], profileinfo->peermac[4], profileinfo->peermac[5]); - if (_rtw_memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) { + if (!memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) { match_result = 1; DBG_88E("[%s] Match!\n", __func__); break; @@ -3939,7 +3943,8 @@ static unsigned int on_action_public_p2p(union recv_frame *precv_frame) /* Commented by Kurt 20120113 */ /* Get peer_dev_addr here if peer doesn't issue prov_disc frame. */ - if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN)) + if (!memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, + ETH_ALEN)) memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); result = process_p2p_group_negotation_req(pwdinfo, frame_body, len); @@ -4021,7 +4026,7 @@ static unsigned int on_action_public_p2p(union recv_frame *precv_frame) _rtw_memset(&group_id, 0x00, sizeof(struct group_id_info)); rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); if (attr_contentlen) { - if (_rtw_memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { + if (!memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { /* The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */ rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO); rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); @@ -4069,7 +4074,7 @@ static unsigned int on_action_public_p2p(union recv_frame *precv_frame) _rtw_memset(&group_id, 0x00, sizeof(struct group_id_info)); rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); if (attr_contentlen) { - if (_rtw_memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { + if (!memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { /* In this case, the GO can't be myself. */ rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; @@ -4116,7 +4121,7 @@ static unsigned int on_action_public_p2p(union recv_frame *precv_frame) pwdinfo->invitereq_info.benable = false; if (attr_content == P2P_STATUS_SUCCESS) { - if (_rtw_memcmp(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv), ETH_ALEN)) { + if (!memcmp(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv), ETH_ALEN)) { rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); } else { rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); @@ -4181,9 +4186,8 @@ static unsigned int on_action_public_vendor(union recv_frame *precv_frame) u8 *pframe = precv_frame->u.hdr.rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); - if (_rtw_memcmp(frame_body + 2, P2P_OUI, 4) == true) { + if (!memcmp(frame_body + 2, P2P_OUI, 4) == true) ret = on_action_public_p2p(precv_frame); - } return ret; } @@ -4214,7 +4218,7 @@ unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_ u8 category, action; /* check RA matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) goto exit; category = frame_body[0]; @@ -4258,7 +4262,7 @@ unsigned int OnAction_p2p(struct adapter *padapter, union recv_frame *precv_fram DBG_88E("%s\n", __func__); /* check RA matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ return _SUCCESS; frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); @@ -5234,7 +5238,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if (pbuf && _rtw_memcmp(pbuf+2, WMM_PARA_IE, 6)) { + if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); pattrib->pktlen += (ie_len+2); @@ -5439,14 +5443,14 @@ void issue_assocreq(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) || - (_rtw_memcmp(pIE->data, WMM_OUI, 4)) || - (_rtw_memcmp(pIE->data, WPS_OUI, 4))) { + if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || + (!memcmp(pIE->data, WMM_OUI, 4)) || + (!memcmp(pIE->data, WPS_OUI, 4))) { if (!padapter->registrypriv.wifi_spec) { /* Commented by Kurt 20110629 */ /* In some older APs, WPS handshake */ /* would be fail if we append vender extensions informations to AP */ - if (_rtw_memcmp(pIE->data, WPS_OUI, 4)) + if (!memcmp(pIE->data, WPS_OUI, 4)) pIE->Length = 14; } pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &(pattrib->pktlen)); @@ -6851,7 +6855,7 @@ unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* check A3 */ - if (!(_rtw_memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + if (memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) return _SUCCESS; DBG_88E("%s\n", __func__); @@ -7902,7 +7906,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ - if (_rtw_memcmp(pIE->data, WMM_OUI, 4)) + if (!memcmp(pIE->data, WMM_OUI, 4)) pmlmeinfo->WMM_enable = 1; break; case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ diff --git a/drivers/staging/rtl8188eu/core/rtw_p2p.c b/drivers/staging/rtl8188eu/core/rtw_p2p.c index 6e8c06e840b3..4a9342dfeb90 100644 --- a/drivers/staging/rtl8188eu/core/rtw_p2p.c +++ b/drivers/staging/rtl8188eu/core/rtw_p2p.c @@ -824,7 +824,7 @@ u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_ , len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_ , NULL, &p2pielen); if (p2pie) { - if ((p != NULL) && _rtw_memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid , 7)) { + if ((p != NULL) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid , 7)) { /* todo: */ /* Check Requested Device Type attributes in WSC IE. */ /* Check Device ID attribute in P2P IE */ @@ -972,8 +972,8 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le u32 attr_contentlen = 0; if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { - if (_rtw_memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && - _rtw_memcmp(pwdinfo->p2p_group_ssid, groupid+ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { + if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && + !memcmp(pwdinfo->p2p_group_ssid, groupid+ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { attr_contentlen = 0; if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_ID, dev_addr, &attr_contentlen)) { struct list_head *phead, *plist; @@ -989,7 +989,7 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le plist = get_next(plist); if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && - _rtw_memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { + !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { /* issue GO Discoverability Request */ issue_group_disc_req(pwdinfo, psta->hwaddr); status = P2P_STATUS_SUCCESS; @@ -1118,7 +1118,7 @@ u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, /* Commented by Kurt 20120113 */ /* If some device wants to do p2p handshake without sending prov_disc_req */ /* We have to get peer_req_cm from here. */ - if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { + if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); wps_devicepassword_id = be16_to_cpu(be_tmp); @@ -2024,11 +2024,11 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) /* Disable P2P function */ if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - _cancel_timer_ex(&pwdinfo->find_phase_timer); - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); - _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); - _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2); + del_timer_sync(&pwdinfo->find_phase_timer); + del_timer_sync(&pwdinfo->restore_p2p_state_timer); + del_timer_sync(&pwdinfo->pre_tx_scan_timer); + del_timer_sync(&pwdinfo->reset_ch_sitesurvey); + del_timer_sync(&pwdinfo->reset_ch_sitesurvey2); reset_ch_sitesurvey_timer_process(padapter); reset_ch_sitesurvey_timer_process2(padapter); rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index f665cbbdda45..b8951a63fa6a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -781,20 +781,20 @@ _func_enter_; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { /* filter packets that SA is myself or multicast or broadcast */ - if (_rtw_memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); ret = _FAIL; goto exit; } - if ((!_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { ret = _FAIL; goto exit; } - if (_rtw_memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - _rtw_memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - !_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; goto exit; } @@ -802,7 +802,7 @@ _func_enter_; sta_addr = pattrib->src; } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ - if (!_rtw_memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { + if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid!=TA under STATION_MODE; drop pkt\n")); ret = _FAIL; goto exit; @@ -817,7 +817,7 @@ _func_enter_; } } else { /* not mc-frame */ /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ - if (!_rtw_memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { + if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { ret = _FAIL; goto exit; } @@ -876,14 +876,14 @@ _func_enter_; (check_fwstate(pmlmepriv, _FW_LINKED) == true || check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { /* filter packets that SA is myself or multicast or broadcast */ - if (_rtw_memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); ret = _FAIL; goto exit; } /* da should be for me */ - if ((!_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, (" ap2sta_data_frame: compare DA fail; DA=%pM\n", (pattrib->dst))); ret = _FAIL; @@ -891,9 +891,9 @@ _func_enter_; } /* check BSSID */ - if (_rtw_memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - _rtw_memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - (!_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, (" ap2sta_data_frame: compare BSSID fail ; BSSID=%pM\n", (pattrib->bssid))); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid=%pM\n", (mybssid))); @@ -949,7 +949,7 @@ _func_enter_; ret = RTW_RX_HANDLED; goto exit; } else { - if (_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { + if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ if (*psta == NULL) { DBG_88E("issue_deauth to the ap =%pM for the reason(7)\n", (pattrib->bssid)); @@ -983,7 +983,7 @@ _func_enter_; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ - if (!_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; goto exit; } @@ -1013,7 +1013,7 @@ _func_enter_; } } else { u8 *myhwaddr = myid(&adapter->eeprompriv); - if (!_rtw_memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { + if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { ret = RTW_RX_HANDLED; goto exit; } @@ -1043,7 +1043,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, return _FAIL; /* receive the frames that ra(a1) is my address */ - if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) return _FAIL; /* only handle ps-poll */ @@ -1180,7 +1180,7 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBEREQ) { psta->sta_stats.rx_probereq_pkts++; } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBERSP) { - if (_rtw_memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN) == true) + if (!memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN) == true) psta->sta_stats.rx_probersp_pkts++; else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) || is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) @@ -1452,10 +1452,10 @@ _func_enter_; psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; /* convert hdr + possible LLC headers into Ethernet header */ - if ((_rtw_memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && - (_rtw_memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) && - (_rtw_memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2) == false)) || - _rtw_memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { + if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && + (!memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) && + (!memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2) == false)) || + !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ bsnaphdr = true; } else { @@ -1767,9 +1767,9 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) /* convert hdr + possible LLC headers into Ethernet header */ eth_type = RTW_GET_BE16(&sub_skb->data[6]); if (sub_skb->len >= 8 && - ((_rtw_memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && + ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || - _rtw_memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { + !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); @@ -2000,7 +2000,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame * spin_unlock_bh(&ppending_recvframe_queue->lock); } else { spin_unlock_bh(&ppending_recvframe_queue->lock); - _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); } _success_exit: diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index e8a654d8db0c..0441bcc1288b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -199,7 +199,7 @@ _func_enter_; for (i = 0; i < 16; i++) { preorder_ctrl = &psta->recvreorder_ctrl[i]; - _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); } } } @@ -354,7 +354,7 @@ _func_enter_; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); - _cancel_timer_ex(&psta->addba_retry_timer); + del_timer_sync(&psta->addba_retry_timer); /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ for (i = 0; i < 16; i++) { @@ -365,7 +365,7 @@ _func_enter_; preorder_ctrl = &psta->recvreorder_ctrl[i]; - _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; @@ -500,7 +500,7 @@ _func_enter_; while ((!rtw_end_of_queue_search(phead, plist))) { psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); - if ((_rtw_memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { + if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { /* if found the matched address */ break; } @@ -567,7 +567,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); - if (_rtw_memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { + if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { if (paclnode->valid) { match = true; break; diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 96df62f95b6b..2c8d58db65fe 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -929,7 +929,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) return _FAIL; } - if (_rtw_memcmp(cur_network->network.MacAddress, pbssid, 6) == false) { + if (!memcmp(cur_network->network.MacAddress, pbssid, 6) == false) { DBG_88E("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n%pM %pM\n", (pbssid), (cur_network->network.MacAddress)); return true; @@ -1014,7 +1014,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid, cur_network->network.Ssid.SsidLength)); - if (!_rtw_memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || + if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) { if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */ DBG_88E("%s(), SSID is not match return FAIL\n", __func__); @@ -1141,11 +1141,11 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) && (_rtw_memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) + if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) return true; break; case _RSN_IE_2_: - if (_rtw_memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) + if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; default: break; @@ -1172,14 +1172,14 @@ unsigned int should_forbid_n_rate(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4) && - ((_rtw_memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || - (_rtw_memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) + if (!memcmp(pIE->data, RTW_WPA_OUI, 4) && + ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || + (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) return false; break; case _RSN_IE_2_: - if ((_rtw_memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || - (_rtw_memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) + if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || + (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) return false; default: break; @@ -1208,7 +1208,7 @@ unsigned int is_ap_in_wep(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) + if (!memcmp(pIE->data, RTW_WPA_OUI, 4)) return false; break; case _RSN_IE_2_: @@ -1400,35 +1400,35 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if ((_rtw_memcmp(pIE->data, ARTHEROS_OUI1, 3)) || - (_rtw_memcmp(pIE->data, ARTHEROS_OUI2, 3))) { + if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || + (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { DBG_88E("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; - } else if ((_rtw_memcmp(pIE->data, BROADCOM_OUI1, 3)) || - (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3)) || - (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3))) { + } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI2, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI2, 3))) { DBG_88E("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; - } else if (_rtw_memcmp(pIE->data, MARVELL_OUI, 3)) { + } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { DBG_88E("link to Marvell AP\n"); return HT_IOT_PEER_MARVELL; - } else if (_rtw_memcmp(pIE->data, RALINK_OUI, 3)) { + } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { if (!ralink_vendor_flag) { ralink_vendor_flag = 1; } else { DBG_88E("link to Ralink AP\n"); return HT_IOT_PEER_RALINK; } - } else if (_rtw_memcmp(pIE->data, CISCO_OUI, 3)) { + } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { DBG_88E("link to Cisco AP\n"); return HT_IOT_PEER_CISCO; - } else if (_rtw_memcmp(pIE->data, REALTEK_OUI, 3)) { + } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { DBG_88E("link to Realtek 96B\n"); return HT_IOT_PEER_REALTEK; - } else if (_rtw_memcmp(pIE->data, AIRGOCAP_OUI, 3)) { + } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { DBG_88E("link to Airgo Cap\n"); return HT_IOT_PEER_AIRGO; - } else if (_rtw_memcmp(pIE->data, EPIGRAM_OUI, 3)) { + } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) { epigram_vendor_flag = 1; if (ralink_vendor_flag) { DBG_88E("link to Tenda W311R AP\n"); diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 5a1d258a1fad..e64607cb8632 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -676,12 +676,12 @@ _func_enter_; pframe = pxmitframe->buf_addr + hw_hdr_offset; if (bmcst) { - if (_rtw_memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) + if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) return _FAIL; /* start to calculate the mic code */ rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { - if (_rtw_memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16) == true) { + if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16) == true) { /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ /* msleep(10); */ return _FAIL; diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index 4b5caa1f397a..056052ddd82e 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -217,7 +217,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( for (i = 0; i < CCK_TABLE_SIZE; i++) { if (dm_odm->RFCalibrateInfo.bCCKinCH14) { - if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { + if (memcmp(&TempCCk, &CCKSwingTable_Ch14[i][2], 4)) { CCK_index_old = (u8)i; dm_odm->BbSwingIdxCckBase = (u8)i; ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, @@ -229,7 +229,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("RegA24: 0x%X, CCKSwingTable_Ch1_Ch13[%d][2]: CCKSwingTable_Ch1_Ch13[i][2]: 0x%X\n", TempCCk, i, CCKSwingTable_Ch1_Ch13[i][2])); - if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { + if (memcmp(&TempCCk, &CCKSwingTable_Ch1_Ch13[i][2], 4)) { CCK_index_old = (u8)i; dm_odm->BbSwingIdxCckBase = (u8)i; ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index fc05e482be77..89a26e3e217f 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1302,8 +1302,8 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) psta = pDM_Odm->pODM_StaInfo[i]; if (IS_STA_VALID(psta) && (psta->state & WIFI_ASOC_STATE) && - !_rtw_memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) && - !_rtw_memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { + memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) && + memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c index 710f8e1620db..8b137891791f 100644 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -1,34 +1 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#include "odm_precomp.h" - -void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) -{ - _cancel_timer_ex(pTimer); -} - -/* ODM FW relative API. */ -u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, - u32 *pElementID, u32 *pCmdLen, - u8 **pCmbBuffer, u8 *CmdStartSeq) -{ - return true; -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index f29c0038c612..524899510355 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -20,6 +20,7 @@ #define _HAL_INIT_C_ #include +#include #include #include diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c b/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c index 3d0e6c9e0310..cd2027b01df4 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c @@ -184,12 +184,12 @@ void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven) TempCCk = read_bbreg(pAdapter, rCCK0_TxFilter2, bMaskDWord) & bMaskCCK; for (i = 0; i < CCK_TABLE_SIZE; i++) { if (pDM_Odm->RFCalibrateInfo.bCCKinCH14) { - if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4)) { + if (!memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4)) { CCK_index_old = (u8)i; break; } } else { - if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4)) { + if (!memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4)) { CCK_index_old = (u8)i; break; } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c index 511f61cbb9e0..4e3630646bd1 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -158,11 +158,11 @@ void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && !pattrib->icv_err && !pattrib->crc_err && - _rtw_memcmp(get_hdr_bssid(wlanhdr), + !memcmp(get_hdr_bssid(wlanhdr), get_bssid(&padapter->mlmepriv), ETH_ALEN)); pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && - (_rtw_memcmp(get_da(wlanhdr), + (!memcmp(get_da(wlanhdr), myid(&padapter->eeprompriv), ETH_ALEN)); pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 495420ebd9ed..e726ff8d0464 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -241,7 +241,6 @@ void *rtw_malloc2d(int h, int w, int size); void rtw_mfree2d(void *pbuf, int h, int w, int size); void _rtw_memcpy(void *dec, void *sour, u32 sz); -int _rtw_memcmp(void *dst, void *src, u32 sz); void _rtw_memset(void *pbuf, int c, u32 sz); void _rtw_init_listhead(struct list_head *list); diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 622b70c39ce0..2579a404a766 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -93,16 +93,6 @@ void rtw_mfree2d(void *pbuf, int h, int w, int size) kfree(pbuf); } -int _rtw_memcmp(void *dst, void *src, u32 sz) -{ -/* under Linux/GNU/GLibc, the return value of memcmp for two same - * mem. chunk is 0 */ - if (!(memcmp(dst, src, sz))) - return true; - else - return false; -} - void _rtw_memset(void *pbuf, int c, u32 sz) { memset(pbuf, c, sz); diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 2a18b3208a00..989b7f1e5e1b 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -170,8 +170,8 @@ _func_enter_; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; int bmcast = IS_MCAST(pattrib->dst); - if (!_rtw_memcmp(pattrib->dst, myid(&padapter->eeprompriv), - ETH_ALEN)) { + if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), + ETH_ALEN)) { if (bmcast) { psta = rtw_get_bcmc_stainfo(padapter); pskb2 = skb_clone(skb, GFP_ATOMIC); From 4090b9f3ddae32ab2bfabe12e2fb715c3fc5d8a4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 9 Feb 2014 15:15:55 -0600 Subject: [PATCH 0120/1375] staging: r8188eu: Remove dead file After the previous cleanups, file hal/odm_interface.c is now empty. It is hereby deleted, and removed from Makefile. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/Makefile | 1 - drivers/staging/rtl8188eu/hal/odm_interface.c | 1 - 2 files changed, 2 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/hal/odm_interface.c diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile index 0a617b42cc99..6a138ff699e9 100644 --- a/drivers/staging/rtl8188eu/Makefile +++ b/drivers/staging/rtl8188eu/Makefile @@ -34,7 +34,6 @@ r8188eu-y := \ hal/hal_com.o \ hal/odm.o \ hal/odm_debug.o \ - hal/odm_interface.o \ hal/odm_HWConfig.o \ hal/odm_RegConfig8188E.o\ hal/odm_RTL8188E.o \ diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c deleted file mode 100644 index 8b137891791f..000000000000 --- a/drivers/staging/rtl8188eu/hal/odm_interface.c +++ /dev/null @@ -1 +0,0 @@ - From 7fdc6ec54e2a59071640bc0206af6951a19d84df Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 9 Feb 2014 15:15:56 -0600 Subject: [PATCH 0121/1375] staging: r8188eu: Remove some dead code from headers The headers for this driver contain a number of unused structs and macros that are removed. File include/ioctl_cfg80211.h is now empty and was deleted. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../rtl8188eu/include/ioctl_cfg80211.h | 107 ------------------ drivers/staging/rtl8188eu/include/rtw_io.h | 44 ------- drivers/staging/rtl8188eu/include/rtw_mlme.h | 32 ------ .../staging/rtl8188eu/os_dep/rtw_android.c | 1 - 4 files changed, 184 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/ioctl_cfg80211.h diff --git a/drivers/staging/rtl8188eu/include/ioctl_cfg80211.h b/drivers/staging/rtl8188eu/include/ioctl_cfg80211.h deleted file mode 100644 index 037e9a5e5af9..000000000000 --- a/drivers/staging/rtl8188eu/include/ioctl_cfg80211.h +++ /dev/null @@ -1,107 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __IOCTL_CFG80211_H__ -#define __IOCTL_CFG80211_H__ - -struct rtw_wdev_invit_info { - u8 token; - u8 flags; - u8 status; - u8 req_op_ch; - u8 rsp_op_ch; -}; - -#define rtw_wdev_invit_info_init(invit_info) \ - do { \ - (invit_info)->token = 0; \ - (invit_info)->flags = 0x00; \ - (invit_info)->status = 0xff; \ - (invit_info)->req_op_ch = 0; \ - (invit_info)->rsp_op_ch = 0; \ - } while (0) - -struct rtw_wdev_priv { - struct wireless_dev *rtw_wdev; - - struct adapter *padapter; - - struct cfg80211_scan_request *scan_request; - spinlock_t scan_req_lock; - - struct net_device *pmon_ndev;/* for monitor interface */ - char ifname_mon[IFNAMSIZ + 1]; /* name of monitor interface */ - - u8 p2p_enabled; - - u8 provdisc_req_issued; - - struct rtw_wdev_invit_info invit_info; - - u8 bandroid_scan; - bool block; - bool power_mgmt; -}; - -#define wdev_to_priv(w) ((struct rtw_wdev_priv *)(wdev_priv(w))) - -#define wiphy_to_wdev(x) \ -((struct wireless_dev *)(((struct rtw_wdev_priv *)wiphy_priv(x))->rtw_wdev)) - -int rtw_wdev_alloc(struct adapter *padapter, struct device *dev); -void rtw_wdev_free(struct wireless_dev *wdev); -void rtw_wdev_unregister(struct wireless_dev *wdev); - -void rtw_cfg80211_init_wiphy(struct adapter *padapter); - -void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter); - -void rtw_cfg80211_indicate_connect(struct adapter *padapter); -void rtw_cfg80211_indicate_disconnect(struct adapter *padapter); -void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, - bool aborted); - -#ifdef CONFIG_88EU_AP_MODE -void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, - u8 *pmgmt_frame, uint frame_len); -void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, - unsigned char *da, - unsigned short reason); -#endif /* CONFIG_88EU_AP_MODE */ - -void rtw_cfg80211_issue_p2p_provision_request(struct adapter *padapter, - const u8 *buf, size_t len); -void rtw_cfg80211_rx_p2p_action_public(struct adapter *padapter, - u8 *pmgmt_frame, uint frame_len); -void rtw_cfg80211_rx_action_p2p(struct adapter *padapter, u8 *pmgmt_frame, - uint frame_len); -void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, - uint frame_len, const char *msg); - -int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, - char *buf, int len, int type); - -bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter); - -#define rtw_cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) \ - cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) -#define rtw_cfg80211_send_rx_assoc(dev, bss, buf, len) \ - cfg80211_send_rx_assoc(dev, bss, buf, len) - -#endif /* __IOCTL_CFG80211_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h index 3d1dfcc1b603..e8790f8f913e 100644 --- a/drivers/staging/rtl8188eu/include/rtw_io.h +++ b/drivers/staging/rtl8188eu/include/rtw_io.h @@ -99,7 +99,6 @@ struct intf_priv; struct intf_hdl; -struct io_queue; struct _io_ops { u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); @@ -117,7 +116,6 @@ struct _io_ops { u8 *pmem); void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - void (*_sync_irp_protocol_rw)(struct io_queue *pio_q); u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); @@ -237,34 +235,11 @@ struct reg_protocol_wt { Below is the data structure used by _io_handler */ -struct io_queue { - spinlock_t lock; - struct list_head free_ioreqs; - struct list_head pending; /* The io_req list that will be served - * in the single protocol read/write.*/ - struct list_head processing; - u8 *free_ioreqs_buf; /* 4-byte aligned */ - u8 *pallocated_free_ioreqs_buf; - struct intf_hdl intf; -}; - struct io_priv { struct adapter *padapter; struct intf_hdl intf; }; -uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); -void sync_ioreq_enqueue(struct io_req *preq, struct io_queue *ioqueue); -uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); -uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue); -struct io_req *alloc_ioreq(struct io_queue *pio_q); - -uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); -void unregister_intf_hdl(struct intf_hdl *pintfhdl); - -void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - u8 _rtw_read8(struct adapter *adapter, u32 addr); u16 _rtw_read16(struct adapter *adapter, u32 addr); u32 _rtw_read32(struct adapter *adapter, u32 addr); @@ -363,25 +338,6 @@ void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct _io_ops *pops)); -uint alloc_io_queue(struct adapter *adapter); -void free_io_queue(struct adapter *adapter); -void async_bus_io(struct io_queue *pio_q); -void bus_sync_io(struct io_queue *pio_q); -u32 _ioreq2rwmem(struct io_queue *pio_q); void dev_power_down(struct adapter *Adapter, u8 bpwrup); -#define PlatformEFIOWrite1Byte(_a, _b, _c) \ - rtw_write8(_a, _b, _c) -#define PlatformEFIOWrite2Byte(_a, _b, _c) \ - rtw_write16(_a, _b, _c) -#define PlatformEFIOWrite4Byte(_a, _b, _c) \ - rtw_write32(_a, _b, _c) - -#define PlatformEFIORead1Byte(_a, _b) \ - rtw_read8(_a, _b) -#define PlatformEFIORead2Byte(_a, _b) \ - rtw_read16(_a, _b) -#define PlatformEFIORead4Byte(_a, _b) \ - rtw_read32(_a, _b) - #endif /* _RTL8711_IO_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index 6cd988f867da..45c22efe93fe 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -106,13 +106,6 @@ SHALL not lock up more than one lock at a time! #define traffic_threshold 10 #define traffic_scan_period 500 -struct sitesurvey_ctrl { - u64 last_tx_pkts; - uint last_rx_pkts; - int traffic_busy; - struct timer_list sitesurvey_ctrl_timer; -}; - struct rt_link_detect { u32 NumTxOkInPeriod; u32 NumRxOkInPeriod; @@ -304,31 +297,6 @@ struct wifidirect_info { u32 noa_start_time[P2P_MAX_NOA_NUM]; }; -struct tdls_ss_record { /* signal strength record */ - u8 macaddr[ETH_ALEN]; - u8 RxPWDBAll; - u8 is_tdls_sta; /* true: direct link sta, false: else */ -}; - -struct tdls_info { - u8 ap_prohibited; - uint setup_state; - u8 sta_cnt; - u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */ - struct tdls_ss_record ss_record; - u8 macid_index; /* macid entry that is ready to write */ - u8 clear_cam; /* cam entry that is trying to clear, using it in direct link teardown */ - u8 ch_sensing; - u8 cur_channel; - u8 candidate_ch; - u8 collect_pkt_num[MAX_CHANNEL_NUM]; - spinlock_t cmd_lock; - spinlock_t hdl_lock; - u8 watchdog_count; - u8 dev_discovered; /* WFD_TDLS: for sigma test */ - u8 enable; -}; - struct mlme_priv { spinlock_t lock; int fw_state; /* shall we protect this variable? maybe not necessarily... */ diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index a3c2bc5922e4..ca2736d60b62 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -24,7 +24,6 @@ #include #include #include -#include #include static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { From bea8810043b9a66c46b8c76bfbb5c8572530788d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 9 Feb 2014 15:15:57 -0600 Subject: [PATCH 0122/1375] staging: r8188eu: Replace misspelled local container macro This driver has its own implementation of a "container_of" macro. It is replaced with the standard container_of version. Most of these are a straight one-to-one replacement; however, a few of the instances referred to the member of a union. Those were replaced with the struct that is part of that union. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 16 +++---- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- drivers/staging/rtl8188eu/core/rtw_debug.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 14 +++--- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 +- drivers/staging/rtl8188eu/core/rtw_p2p.c | 4 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 44 ++++++++++--------- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 16 ++++--- drivers/staging/rtl8188eu/core/rtw_xmit.c | 20 ++++----- .../staging/rtl8188eu/hal/rtl8188eu_xmit.c | 2 +- .../staging/rtl8188eu/include/osdep_service.h | 4 -- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 26 +++++------ drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 2 +- 13 files changed, 78 insertions(+), 78 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index fe5ec8eba7f6..f32011cde44a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -289,7 +289,7 @@ void expire_timeout_chk(struct adapter *padapter) /* check auth_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); + psta = container_of(plist, struct sta_info, auth_list); plist = get_next(plist); if (psta->expire_to > 0) { @@ -323,7 +323,7 @@ void expire_timeout_chk(struct adapter *padapter) /* check asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); if (chk_sta_is_alive(psta) || !psta->expire_to) { @@ -1147,7 +1147,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) plist = get_next(phead); while (!rtw_end_of_queue_search(phead, plist)) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { @@ -1208,7 +1208,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) plist = get_next(phead); while (!rtw_end_of_queue_search(phead, plist)) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { @@ -1507,7 +1507,7 @@ void associated_clients_update(struct adapter *padapter, u8 updated) /* check asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -1781,7 +1781,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) /* for each sta in asoc_queue */ while (!rtw_end_of_queue_search(phead, plist)) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset); @@ -1815,7 +1815,7 @@ int rtw_sta_flush(struct adapter *padapter) /* free sta asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -1944,7 +1944,7 @@ void stop_ap_mode(struct adapter *padapter) phead = get_list_head(pacl_node_q); plist = get_next(phead); while ((rtw_end_of_queue_search(phead, plist)) == false) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (paclnode->valid) { diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 82fe8c47a1de..d24252de84f9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -173,7 +173,7 @@ _func_enter_; if (rtw_is_list_empty(&(queue->queue))) { obj = NULL; } else { - obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, list); + obj = container_of(get_next(&(queue->queue)), struct cmd_obj, list); rtw_list_delete(&obj->list); } diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c index af32041a1e97..76e7b7b582f0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_debug.c +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -854,7 +854,7 @@ int proc_get_all_sta_info(char *page, char **start, plist = get_next(phead); while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = get_next(plist); diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 4f482e23e785..55090d7074dd 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -167,7 +167,7 @@ _func_enter_; if (_rtw_queue_empty(queue)) { pnetwork = NULL; } else { - pnetwork = LIST_CONTAINOR(get_next(&queue->queue), struct wlan_network, list); + pnetwork = container_of(get_next(&queue->queue), struct wlan_network, list); rtw_list_delete(&(pnetwork->list)); } @@ -195,7 +195,7 @@ _func_enter_; } plist = get_next(&(free_queue->queue)); - pnetwork = LIST_CONTAINOR(plist , struct wlan_network, list); + pnetwork = container_of(plist , struct wlan_network, list); rtw_list_delete(&pnetwork->list); @@ -285,7 +285,7 @@ _func_enter_; plist = get_next(phead); while (plist != phead) { - pnetwork = LIST_CONTAINOR(plist, struct wlan_network , list); + pnetwork = container_of(plist, struct wlan_network , list); if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) break; plist = get_next(plist); @@ -314,7 +314,7 @@ _func_enter_; plist = get_next(phead); while (rtw_end_of_queue_search(phead, plist) == false) { - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); plist = get_next(plist); @@ -500,7 +500,7 @@ _func_enter_; if (rtw_end_of_queue_search(phead, plist) == true) break; - pwlan = LIST_CONTAINOR(plist, struct wlan_network, list); + pwlan = container_of(plist, struct wlan_network, list); if (!pwlan->fixed) { if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) @@ -593,7 +593,7 @@ _func_enter_; if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (is_same_network(&(pnetwork->network), target)) break; @@ -1749,7 +1749,7 @@ _func_enter_; adapter = (struct adapter *)pmlmepriv->nic_hdl; pmlmepriv->pscanned = get_next(phead); while (!rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) { - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); if (pnetwork == NULL) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork==NULL)\n", __func__)); ret = _FAIL; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index ce9658617f2e..8e923352d1e9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -6236,7 +6236,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) if (rtw_end_of_queue_search(phead, plist)) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); plist = get_next(plist); @@ -8375,7 +8375,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) xmitframe_plist = get_next(xmitframe_phead); while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); diff --git a/drivers/staging/rtl8188eu/core/rtw_p2p.c b/drivers/staging/rtl8188eu/core/rtw_p2p.c index 4a9342dfeb90..e91a2eeb2084 100644 --- a/drivers/staging/rtl8188eu/core/rtw_p2p.c +++ b/drivers/staging/rtl8188eu/core/rtw_p2p.c @@ -61,7 +61,7 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) /* look up sta asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -984,7 +984,7 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le /* look up sta asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index b8951a63fa6a..8ef31902f928 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -138,23 +138,23 @@ _func_exit_; union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) { - union recv_frame *precvframe; + struct recv_frame_hdr *hdr; struct list_head *plist, *phead; struct adapter *padapter; struct recv_priv *precvpriv; _func_enter_; if (_rtw_queue_empty(pfree_recv_queue)) { - precvframe = NULL; + hdr = NULL; } else { phead = get_list_head(pfree_recv_queue); plist = get_next(phead); - precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + hdr = container_of(plist, struct recv_frame_hdr, list); - rtw_list_delete(&precvframe->u.hdr.list); - padapter = precvframe->u.hdr.adapter; + rtw_list_delete(&hdr->list); + padapter = hdr->adapter; if (padapter != NULL) { precvpriv = &padapter->recvpriv; if (pfree_recv_queue == &precvpriv->free_recv_queue) @@ -164,7 +164,7 @@ _func_enter_; _func_exit_; - return precvframe; + return (union recv_frame *)hdr; } union recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) @@ -264,7 +264,7 @@ using spinlock to protect void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) { - union recv_frame *precvframe; + struct recv_frame_hdr *hdr; struct list_head *plist, *phead; _func_enter_; @@ -274,11 +274,11 @@ _func_enter_; plist = get_next(phead); while (rtw_end_of_queue_search(phead, plist) == false) { - precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + hdr = container_of(plist, struct recv_frame_hdr, list); plist = get_next(plist); - rtw_free_recvframe(precvframe, pfree_recv_queue); + rtw_free_recvframe((union recv_frame *)hdr, pfree_recv_queue); } spin_unlock(&pframequeue->lock); @@ -338,7 +338,7 @@ struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) plist = get_next(phead); - precvbuf = LIST_CONTAINOR(plist, struct recv_buf, list); + precvbuf = container_of(plist, struct recv_buf, list); rtw_list_delete(&precvbuf->list); } @@ -1100,7 +1100,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, xmitframe_plist = get_next(xmitframe_phead); if ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -1516,8 +1516,8 @@ _func_enter_; phead = get_list_head(defrag_q); plist = get_next(phead); - prframe = LIST_CONTAINOR(plist, union recv_frame, u); - pfhdr = &prframe->u.hdr; + pfhdr = container_of(plist, struct recv_frame_hdr, list); + prframe = (union recv_frame *)pfhdr; rtw_list_delete(&(prframe->u.list)); if (curfragnum != pfhdr->attrib.frag_num) { @@ -1536,8 +1536,8 @@ _func_enter_; plist = get_next(plist); while (rtw_end_of_queue_search(phead, plist) == false) { - pnextrframe = LIST_CONTAINOR(plist, union recv_frame , u); - pnfhdr = &pnextrframe->u.hdr; + pnfhdr = container_of(plist, struct recv_frame_hdr , list); + pnextrframe = (union recv_frame *)pnfhdr; /* check the fragment sequence (2nd ~n fragment frame) */ @@ -1837,15 +1837,15 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; struct list_head *phead, *plist; - union recv_frame *pnextrframe; + struct recv_frame_hdr *hdr; struct rx_pkt_attrib *pnextattrib; phead = get_list_head(ppending_recvframe_queue); plist = get_next(phead); while (rtw_end_of_queue_search(phead, plist) == false) { - pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); - pnextattrib = &pnextrframe->u.hdr.attrib; + hdr = container_of(plist, struct recv_frame_hdr, list); + pnextattrib = &hdr->attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) plist = get_next(plist); @@ -1865,6 +1865,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor { struct list_head *phead, *plist; union recv_frame *prframe; + struct recv_frame_hdr *prhdr; struct rx_pkt_attrib *pattrib; int bPktInBuf = false; struct recv_priv *precvpriv = &padapter->recvpriv; @@ -1878,15 +1879,16 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor if (rtw_is_list_empty(phead)) return true; - prframe = LIST_CONTAINOR(plist, union recv_frame, u); - pattrib = &prframe->u.hdr.attrib; + prhdr = container_of(plist, struct recv_frame_hdr, list); + pattrib = &prhdr->attrib; preorder_ctrl->indicate_seq = pattrib->seq_num; } /* Prepare indication list and indication. */ /* Check if there is any packet need indicate. */ while (!rtw_is_list_empty(phead)) { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + prhdr = container_of(plist, struct recv_frame_hdr, list); + prframe = (union recv_frame *)prhdr; pattrib = &prframe->u.hdr.attrib; if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 0441bcc1288b..6f870b87c0ac 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -163,7 +163,7 @@ _func_enter_; plist = get_next(phead); while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info , list); + psta = container_of(plist, struct sta_info , list); plist = get_next(plist); } @@ -194,7 +194,7 @@ _func_enter_; while ((rtw_end_of_queue_search(phead, plist)) == false) { int i; - psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); + psta = container_of(plist, struct sta_info , hash_list); plist = get_next(plist); for (i = 0; i < 16; i++) { @@ -236,7 +236,7 @@ _func_enter_; spin_unlock_bh(&pfree_sta_queue->lock); psta = NULL; } else { - psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list); + psta = container_of(get_next(&pfree_sta_queue->queue), struct sta_info, list); rtw_list_delete(&(psta->list)); spin_unlock_bh(&pfree_sta_queue->lock); _rtw_init_stainfo(psta); @@ -359,6 +359,7 @@ _func_enter_; /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ for (i = 0; i < 16; i++) { struct list_head *phead, *plist; + struct recv_frame_hdr *prhdr; union recv_frame *prframe; struct __queue *ppending_recvframe_queue; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; @@ -375,7 +376,8 @@ _func_enter_; plist = get_next(phead); while (!rtw_is_list_empty(phead)) { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + prhdr = container_of(plist, struct recv_frame_hdr, list); + prframe = (union recv_frame *)prhdr; plist = get_next(plist); @@ -455,7 +457,7 @@ _func_enter_; plist = get_next(phead); while ((!rtw_end_of_queue_search(phead, plist))) { - psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); + psta = container_of(plist, struct sta_info , hash_list); plist = get_next(plist); @@ -498,7 +500,7 @@ _func_enter_; plist = get_next(phead); while ((!rtw_end_of_queue_search(phead, plist))) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { /* if found the matched address */ @@ -564,7 +566,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) phead = get_list_head(pacl_node_q); plist = get_next(phead); while ((!rtw_end_of_queue_search(phead, plist))) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index e64607cb8632..8658ba655380 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1261,7 +1261,7 @@ _func_enter_; plist = get_next(phead); - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); rtw_list_delete(&(pxmitbuf->list)); } @@ -1329,7 +1329,7 @@ _func_enter_; plist = get_next(phead); - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); rtw_list_delete(&(pxmitbuf->list)); } @@ -1417,7 +1417,7 @@ _func_enter_; plist = get_next(phead); - pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxframe = container_of(plist, struct xmit_frame, list); rtw_list_delete(&(pxframe->list)); } @@ -1501,7 +1501,7 @@ _func_enter_; plist = get_next(phead); while (!rtw_end_of_queue_search(phead, plist)) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxmitframe = container_of(plist, struct xmit_frame, list); plist = get_next(plist); @@ -1533,7 +1533,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str xmitframe_plist = get_next(xmitframe_phead); if (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -1575,7 +1575,7 @@ _func_enter_; sta_plist = get_next(sta_phead); while (!rtw_end_of_queue_search(sta_phead, sta_plist)) { - ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); + ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); pframe_queue = &ptxservq->sta_pending; @@ -2073,7 +2073,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc plist = get_next(phead); while (!rtw_end_of_queue_search(phead, plist)) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxmitframe = container_of(plist, struct xmit_frame, list); plist = get_next(plist); @@ -2140,7 +2140,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) xmitframe_plist = get_next(xmitframe_phead); while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -2221,7 +2221,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) xmitframe_plist = get_next(xmitframe_phead); while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -2268,7 +2268,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst xmitframe_plist = get_next(xmitframe_phead); while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 6fb6a46f04fe..50bc215b12ba 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -540,7 +540,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp xmitframe_plist = get_next(xmitframe_phead); while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); pxmitframe->agg_num = 0; /* not first frame of aggregation */ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index e726ff8d0464..59399210a891 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -72,10 +72,6 @@ static inline struct list_head *get_list_head(struct __queue *queue) return &(queue->queue); } - -#define LIST_CONTAINOR(ptr, type, member) \ - ((type *)((char *)(ptr)-(size_t)(&((type *)0)->member))) - static inline int _enter_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) { diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index f3584dd832e2..f9e52b3ac876 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1145,7 +1145,7 @@ static int rtw_wx_set_wap(struct net_device *dev, if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true) break; - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); @@ -1452,7 +1452,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, break; } - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) @@ -1541,7 +1541,7 @@ static int rtw_wx_set_essid(struct net_device *dev, break; } - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); @@ -2614,7 +2614,7 @@ static int rtw_get_ap_info(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (hwaddr_aton_i(data, bssid)) { DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); @@ -3117,7 +3117,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { u8 *wpsie; uint wpsie_len = 0; @@ -3187,7 +3187,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { /* Commented by Albert 2011/05/18 */ /* Match the device address located in the P2P IE */ @@ -3271,7 +3271,7 @@ static int rtw_p2p_get_device_type(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { u8 *wpsie; uint wpsie_len = 0; @@ -3350,7 +3350,7 @@ static int rtw_p2p_get_device_name(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { u8 *wpsie; uint wpsie_len = 0; @@ -3421,7 +3421,7 @@ static int rtw_p2p_get_invitation_procedure(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { /* Commented by Albert 20121226 */ /* Match the device address located in the P2P IE */ @@ -3503,7 +3503,7 @@ static int rtw_p2p_connect(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { uintPeerChannel = pnetwork->network.Configuration.DSConfig; break; @@ -3598,7 +3598,7 @@ static int rtw_p2p_invite_req(struct net_device *dev, if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); /* Commented by Albert 2011/05/18 */ /* Match the device address located in the P2P IE */ @@ -3751,7 +3751,7 @@ static int rtw_p2p_prov_disc(struct net_device *dev, if (uintPeerChannel != 0) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); /* Commented by Albert 2011/05/18 */ /* Match the device address located in the P2P IE */ @@ -4440,7 +4440,7 @@ static int rtw_dbg_port(struct net_device *dev, plist = get_next(phead); while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = get_next(plist); diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 8097903f3b68..c1b7c9629edf 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -202,7 +202,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) /* free sta asoc_queue */ while (!rtw_end_of_queue_search(phead, plist)) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); From c44e5e39c3d168d094cfe91334fd9e826de7d51f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 9 Feb 2014 15:15:58 -0600 Subject: [PATCH 0123/1375] staging: r8188eu: Eliminate macro to get next list item The driver contains a macro that gets the next item in a linked list. Replace it with a simple copy of the pointer. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 32 ++++++------ drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- drivers/staging/rtl8188eu/core/rtw_debug.c | 4 +- .../staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 28 +++++----- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +-- drivers/staging/rtl8188eu/core/rtw_p2p.c | 8 +-- drivers/staging/rtl8188eu/core/rtw_recv.c | 26 +++++----- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 26 +++++----- drivers/staging/rtl8188eu/core/rtw_xmit.c | 34 ++++++------ .../staging/rtl8188eu/hal/rtl8188eu_xmit.c | 4 +- .../staging/rtl8188eu/include/osdep_service.h | 5 -- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 52 +++++++++---------- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 4 +- 14 files changed, 115 insertions(+), 120 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index f32011cde44a..62a614706308 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -285,12 +285,12 @@ void expire_timeout_chk(struct adapter *padapter) spin_lock_bh(&pstapriv->auth_list_lock); phead = &pstapriv->auth_list; - plist = get_next(phead); + plist = phead->next; /* check auth_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, auth_list); - plist = get_next(plist); + plist = plist->next; if (psta->expire_to > 0) { psta->expire_to--; @@ -319,12 +319,12 @@ void expire_timeout_chk(struct adapter *padapter) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* check asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; if (chk_sta_is_alive(psta) || !psta->expire_to) { psta->expire_to = pstapriv->expire_to; @@ -1144,11 +1144,11 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); + plist = phead->next; while (!rtw_end_of_queue_search(phead, plist)) { paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + plist = plist->next; if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { @@ -1205,11 +1205,11 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); + plist = phead->next; while (!rtw_end_of_queue_search(phead, plist)) { paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + plist = plist->next; if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { @@ -1503,13 +1503,13 @@ void associated_clients_update(struct adapter *padapter, u8 updated) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* check asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; VCS_update(padapter, psta); } @@ -1777,12 +1777,12 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* for each sta in asoc_queue */ while (!rtw_end_of_queue_search(phead, plist)) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset); psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); @@ -1811,13 +1811,13 @@ int rtw_sta_flush(struct adapter *padapter) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* free sta asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; rtw_list_delete(&psta->asoc_list); pstapriv->asoc_list_cnt--; @@ -1942,10 +1942,10 @@ void stop_ap_mode(struct adapter *padapter) /* for ACL */ spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); + plist = phead->next; while ((rtw_end_of_queue_search(phead, plist)) == false) { paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + plist = plist->next; if (paclnode->valid) { paclnode->valid = false; diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index d24252de84f9..cc322e5b0d6c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -173,7 +173,7 @@ _func_enter_; if (rtw_is_list_empty(&(queue->queue))) { obj = NULL; } else { - obj = container_of(get_next(&(queue->queue)), struct cmd_obj, list); + obj = container_of((&queue->queue)->next, struct cmd_obj, list); rtw_list_delete(&obj->list); } diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c index 76e7b7b582f0..1812ba9659b8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_debug.c +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -851,12 +851,12 @@ int proc_get_all_sta_info(char *page, char **start, for (i = 0; i < NUM_STA; i++) { phead = &(pstapriv->sta_hash[i]); - plist = get_next(phead); + plist = phead->next; while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, hash_list); - plist = get_next(plist); + plist = plist->next; len += snprintf(page + len, count - len, "sta's macaddr: %pM\n", psta->hwaddr); len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 125ba4c70bf2..0f0f515b0596 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -78,7 +78,7 @@ _func_enter_; spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 55090d7074dd..700a34d73c2d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -167,7 +167,7 @@ _func_enter_; if (_rtw_queue_empty(queue)) { pnetwork = NULL; } else { - pnetwork = container_of(get_next(&queue->queue), struct wlan_network, list); + pnetwork = container_of((&queue->queue)->next, struct wlan_network, list); rtw_list_delete(&(pnetwork->list)); } @@ -193,7 +193,7 @@ _func_enter_; pnetwork = NULL; goto exit; } - plist = get_next(&(free_queue->queue)); + plist = free_queue->queue.next; pnetwork = container_of(plist , struct wlan_network, list); @@ -282,13 +282,13 @@ _func_enter_; goto exit; } phead = get_list_head(scanned_queue); - plist = get_next(phead); + plist = phead->next; while (plist != phead) { pnetwork = container_of(plist, struct wlan_network , list); if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) break; - plist = get_next(plist); + plist = plist->next; } if (plist == phead) pnetwork = NULL; @@ -311,12 +311,12 @@ _func_enter_; spin_lock_bh(&scanned_queue->lock); phead = get_list_head(scanned_queue); - plist = get_next(phead); + plist = phead->next; while (rtw_end_of_queue_search(phead, plist) == false) { pnetwork = container_of(plist, struct wlan_network, list); - plist = get_next(plist); + plist = plist->next; _rtw_free_network(pmlmepriv, pnetwork, isfreeall); } @@ -494,7 +494,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) _func_enter_; phead = get_list_head(scanned_queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -507,7 +507,7 @@ _func_enter_; oldest = pwlan; } - plist = get_next(plist); + plist = plist->next; } _func_exit_; return oldest; @@ -587,7 +587,7 @@ _func_enter_; spin_lock_bh(&queue->lock); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -600,7 +600,7 @@ _func_enter_; if ((oldest == ((struct wlan_network *)0)) || time_after(oldest->last_scanned, pnetwork->last_scanned)) oldest = pnetwork; - plist = get_next(plist); + plist = plist->next; } /* If we didn't find a match, then get a new network slot to initialize * with this beacon's information */ @@ -908,10 +908,10 @@ _func_enter_; spin_lock_bh(&free_queue->lock); phead = get_list_head(scan_queue); - plist = get_next(phead); + plist = phead->next; while (plist != phead) { - ptemp = get_next(plist); + ptemp = plist->next; rtw_list_delete(plist); rtw_list_insert_tail(plist, &free_queue->queue); plist = ptemp; @@ -1747,7 +1747,7 @@ _func_enter_; spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); adapter = (struct adapter *)pmlmepriv->nic_hdl; - pmlmepriv->pscanned = get_next(phead); + pmlmepriv->pscanned = phead->next; while (!rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) { pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); if (pnetwork == NULL) { @@ -1755,7 +1755,7 @@ _func_enter_; ret = _FAIL; goto exit; } - pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + pmlmepriv->pscanned = pmlmepriv->pscanned->next; rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); } if (candidate == NULL) { diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 8e923352d1e9..2c5d704b0a4d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -6226,7 +6226,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { int len; @@ -6238,7 +6238,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pnetwork = container_of(plist, struct wlan_network, list); - plist = get_next(plist); + plist = plist->next; pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; @@ -8372,12 +8372,12 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; rtw_list_delete(&pxmitframe->list); diff --git a/drivers/staging/rtl8188eu/core/rtw_p2p.c b/drivers/staging/rtl8188eu/core/rtw_p2p.c index e91a2eeb2084..4670eb371a9d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_p2p.c +++ b/drivers/staging/rtl8188eu/core/rtw_p2p.c @@ -57,13 +57,13 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* look up sta asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; if (psta->is_p2p_device) { @@ -980,13 +980,13 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* look up sta asoc_queue */ while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 8ef31902f928..e624afe0f86b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -149,7 +149,7 @@ _func_enter_; } else { phead = get_list_head(pfree_recv_queue); - plist = get_next(phead); + plist = phead->next; hdr = container_of(plist, struct recv_frame_hdr, list); @@ -271,12 +271,12 @@ _func_enter_; spin_lock(&pframequeue->lock); phead = get_list_head(pframequeue); - plist = get_next(phead); + plist = phead->next; while (rtw_end_of_queue_search(phead, plist) == false) { hdr = container_of(plist, struct recv_frame_hdr, list); - plist = get_next(plist); + plist = plist->next; rtw_free_recvframe((union recv_frame *)hdr, pfree_recv_queue); } @@ -336,7 +336,7 @@ struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) } else { phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; precvbuf = container_of(plist, struct recv_buf, list); @@ -1097,12 +1097,12 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, spin_lock_bh(&psta->sleep_q.lock); xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; if ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; rtw_list_delete(&pxmitframe->list); @@ -1515,7 +1515,7 @@ _func_enter_; pfree_recv_queue = &adapter->recvpriv.free_recv_queue; phead = get_list_head(defrag_q); - plist = get_next(phead); + plist = phead->next; pfhdr = container_of(plist, struct recv_frame_hdr, list); prframe = (union recv_frame *)pfhdr; rtw_list_delete(&(prframe->u.list)); @@ -1533,7 +1533,7 @@ _func_enter_; plist = get_list_head(defrag_q); - plist = get_next(plist); + plist = plist->next; while (rtw_end_of_queue_search(phead, plist) == false) { pnfhdr = container_of(plist, struct recv_frame_hdr , list); @@ -1567,7 +1567,7 @@ _func_enter_; recvframe_put(prframe, pnfhdr->len); pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len; - plist = get_next(plist); + plist = plist->next; } /* free the defrag_q queue and return the prframe */ @@ -1841,14 +1841,14 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec struct rx_pkt_attrib *pnextattrib; phead = get_list_head(ppending_recvframe_queue); - plist = get_next(phead); + plist = phead->next; while (rtw_end_of_queue_search(phead, plist) == false) { hdr = container_of(plist, struct recv_frame_hdr, list); pnextattrib = &hdr->attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) - plist = get_next(plist); + plist = plist->next; else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) return false; else @@ -1872,7 +1872,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; phead = get_list_head(ppending_recvframe_queue); - plist = get_next(phead); + plist = phead->next; /* Handling some condition for forced indicate case. */ if (bforced) { @@ -1895,7 +1895,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_indicatepkts_in_order: indicate=%d seq=%d amsdu=%d\n", preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); - plist = get_next(plist); + plist = plist->next; rtw_list_delete(&(prframe->u.hdr.list)); if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 6f870b87c0ac..5c9326d12f5f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -160,11 +160,11 @@ _func_enter_; spin_lock_bh(&pstapriv->sta_hash_lock); phead = get_list_head(&pstapriv->free_sta_queue); - plist = get_next(phead); + plist = phead->next; while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info , list); - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pstapriv->sta_hash_lock); @@ -190,12 +190,12 @@ _func_enter_; spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { phead = &(pstapriv->sta_hash[index]); - plist = get_next(phead); + plist = phead->next; while ((rtw_end_of_queue_search(phead, plist)) == false) { int i; psta = container_of(plist, struct sta_info , hash_list); - plist = get_next(plist); + plist = plist->next; for (i = 0; i < 16; i++) { preorder_ctrl = &psta->recvreorder_ctrl[i]; @@ -236,7 +236,7 @@ _func_enter_; spin_unlock_bh(&pfree_sta_queue->lock); psta = NULL; } else { - psta = container_of(get_next(&pfree_sta_queue->queue), struct sta_info, list); + psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list); rtw_list_delete(&(psta->list)); spin_unlock_bh(&pfree_sta_queue->lock); _rtw_init_stainfo(psta); @@ -373,13 +373,13 @@ _func_enter_; spin_lock_bh(&ppending_recvframe_queue->lock); phead = get_list_head(ppending_recvframe_queue); - plist = get_next(phead); + plist = phead->next; while (!rtw_is_list_empty(phead)) { prhdr = container_of(plist, struct recv_frame_hdr, list); prframe = (union recv_frame *)prhdr; - plist = get_next(plist); + plist = plist->next; rtw_list_delete(&(prframe->u.hdr.list)); @@ -454,12 +454,12 @@ _func_enter_; for (index = 0; index < NUM_STA; index++) { phead = &(pstapriv->sta_hash[index]); - plist = get_next(phead); + plist = phead->next; while ((!rtw_end_of_queue_search(phead, plist))) { psta = container_of(plist, struct sta_info , hash_list); - plist = get_next(plist); + plist = plist->next; if (pbcmc_stainfo != psta) rtw_free_stainfo(padapter , psta); @@ -497,7 +497,7 @@ _func_enter_; spin_lock_bh(&pstapriv->sta_hash_lock); phead = &(pstapriv->sta_hash[index]); - plist = get_next(phead); + plist = phead->next; while ((!rtw_end_of_queue_search(phead, plist))) { psta = container_of(plist, struct sta_info, hash_list); @@ -507,7 +507,7 @@ _func_enter_; break; } psta = NULL; - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pstapriv->sta_hash_lock); @@ -564,10 +564,10 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); + plist = phead->next; while ((!rtw_end_of_queue_search(phead, plist))) { paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + plist = plist->next; if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { if (paclnode->valid) { diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 8658ba655380..3b584b450941 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1259,7 +1259,7 @@ _func_enter_; } else { phead = get_list_head(pfree_queue); - plist = get_next(phead); + plist = phead->next; pxmitbuf = container_of(plist, struct xmit_buf, list); @@ -1327,7 +1327,7 @@ _func_enter_; } else { phead = get_list_head(pfree_xmitbuf_queue); - plist = get_next(phead); + plist = phead->next; pxmitbuf = container_of(plist, struct xmit_buf, list); @@ -1415,7 +1415,7 @@ _func_enter_; } else { phead = get_list_head(pfree_xmit_queue); - plist = get_next(phead); + plist = phead->next; pxframe = container_of(plist, struct xmit_frame, list); @@ -1498,12 +1498,12 @@ _func_enter_; spin_lock_bh(&(pframequeue->lock)); phead = get_list_head(pframequeue); - plist = get_next(phead); + plist = phead->next; while (!rtw_end_of_queue_search(phead, plist)) { pxmitframe = container_of(plist, struct xmit_frame, list); - plist = get_next(plist); + plist = plist->next; rtw_free_xmitframe(pxmitpriv, pxmitframe); } @@ -1530,12 +1530,12 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str struct xmit_frame *pxmitframe = NULL; xmitframe_phead = get_list_head(pframe_queue); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; if (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; rtw_list_delete(&pxmitframe->list); @@ -1572,7 +1572,7 @@ _func_enter_; phwxmit = phwxmit_i + inx[i]; sta_phead = get_list_head(phwxmit->sta_queue); - sta_plist = get_next(sta_phead); + sta_plist = sta_phead->next; while (!rtw_end_of_queue_search(sta_phead, sta_plist)) { ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); @@ -1590,7 +1590,7 @@ _func_enter_; goto exit; } - sta_plist = get_next(sta_plist); + sta_plist = sta_plist->next; } } exit: @@ -2070,12 +2070,12 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; phead = get_list_head(pframequeue); - plist = get_next(phead); + plist = phead->next; while (!rtw_end_of_queue_search(phead, plist)) { pxmitframe = container_of(plist, struct xmit_frame, list); - plist = get_next(plist); + plist = plist->next; xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe); @@ -2137,12 +2137,12 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) spin_lock_bh(&psta->sleep_q.lock); xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; rtw_list_delete(&pxmitframe->list); @@ -2218,12 +2218,12 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; rtw_list_delete(&pxmitframe->list); @@ -2265,12 +2265,12 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst spin_lock_bh(&psta->sleep_q.lock); xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; switch (pxmitframe->attrib.priority) { case 1: diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 50bc215b12ba..3476f8898330 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -537,11 +537,11 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp spin_lock_bh(&pxmitpriv->lock); xmitframe_phead = get_list_head(&ptxservq->sta_pending); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; pxmitframe->agg_num = 0; /* not first frame of aggregation */ pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 59399210a891..09e2d487df8c 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -62,11 +62,6 @@ struct __queue { spinlock_t lock; }; -static inline struct list_head *get_next(struct list_head *list) -{ - return list->next; -} - static inline struct list_head *get_list_head(struct __queue *queue) { return &(queue->queue); diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index f9e52b3ac876..08be34ef5e14 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1139,7 +1139,7 @@ static int rtw_wx_set_wap(struct net_device *dev, authmode = padapter->securitypriv.ndisauthtype; spin_lock_bh(&queue->lock); phead = get_list_head(queue); - pmlmepriv->pscanned = get_next(phead); + pmlmepriv->pscanned = phead->next; while (1) { if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true) @@ -1147,7 +1147,7 @@ static int rtw_wx_set_wap(struct net_device *dev, pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); - pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + pmlmepriv->pscanned = pmlmepriv->pscanned->next; dst_bssid = pnetwork->network.MacAddress; @@ -1441,7 +1441,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist)) @@ -1458,7 +1458,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) ev = translate_scan(padapter, a, pnetwork, ev, stop); - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -1531,7 +1531,7 @@ static int rtw_wx_set_essid(struct net_device *dev, RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); spin_lock_bh(&queue->lock); phead = get_list_head(queue); - pmlmepriv->pscanned = get_next(phead); + pmlmepriv->pscanned = phead->next; while (1) { if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) { @@ -1543,7 +1543,7 @@ static int rtw_wx_set_essid(struct net_device *dev, pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); - pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + pmlmepriv->pscanned = pmlmepriv->pscanned->next; dst_ssid = pnetwork->network.Ssid.Ssid; @@ -2608,7 +2608,7 @@ static int rtw_get_ap_info(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -2639,7 +2639,7 @@ static int rtw_get_ap_info(struct net_device *dev, } } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3111,7 +3111,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3135,7 +3135,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, } break; } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3181,7 +3181,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3216,7 +3216,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, } } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3265,7 +3265,7 @@ static int rtw_p2p_get_device_type(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3296,7 +3296,7 @@ static int rtw_p2p_get_device_type(struct net_device *dev, break; } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3344,7 +3344,7 @@ static int rtw_p2p_get_device_name(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3367,7 +3367,7 @@ static int rtw_p2p_get_device_name(struct net_device *dev, break; } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3415,7 +3415,7 @@ static int rtw_p2p_get_invitation_procedure(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3441,7 +3441,7 @@ static int rtw_p2p_get_invitation_procedure(struct net_device *dev, } } } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3497,7 +3497,7 @@ static int rtw_p2p_connect(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3509,7 +3509,7 @@ static int rtw_p2p_connect(struct net_device *dev, break; } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3592,7 +3592,7 @@ static int rtw_p2p_invite_req(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3623,7 +3623,7 @@ static int rtw_p2p_invite_req(struct net_device *dev, } } } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -3742,7 +3742,7 @@ static int rtw_p2p_prov_disc(struct net_device *dev, spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; while (1) { if (rtw_end_of_queue_search(phead, plist) == true) @@ -3782,7 +3782,7 @@ static int rtw_p2p_prov_disc(struct net_device *dev, } } - plist = get_next(plist); + plist = plist->next; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -4437,12 +4437,12 @@ static int rtw_dbg_port(struct net_device *dev, for (i = 0; i < NUM_STA; i++) { phead = &(pstapriv->sta_hash[i]); - plist = get_next(phead); + plist = phead->next; while ((rtw_end_of_queue_search(phead, plist)) == false) { psta = container_of(plist, struct sta_info, hash_list); - plist = get_next(plist); + plist = plist->next; if (extra_arg == psta->aid) { DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index c1b7c9629edf..5ea00c35439b 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -198,13 +198,13 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* free sta asoc_queue */ while (!rtw_end_of_queue_search(phead, plist)) { psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; /* avoid come from STA1 and send back STA1 */ if (!memcmp(psta->hwaddr, &skb->data[6], 6)) From f578b5d33ee721461921c8e79e5f8b309b2e604d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 9 Feb 2014 15:15:59 -0600 Subject: [PATCH 0124/1375] staging: r8188eu: Remove _func_enter and _func_exit macros These debugging macros are seldom used for debugging once the driver is working. If routine tracing is needed, it can be added on an individual basis. In a few cases, removal of the exit macro left a bare label. In these cases, a go to that label was replaced by a return. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 112 +------------ .../staging/rtl8188eu/core/rtw_ieee80211.c | 13 -- drivers/staging/rtl8188eu/core/rtw_io.c | 28 ---- .../staging/rtl8188eu/core/rtw_ioctl_set.c | 25 --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 158 ++---------------- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 - drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c | 78 --------- drivers/staging/rtl8188eu/core/rtw_p2p.c | 18 -- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 25 --- drivers/staging/rtl8188eu/core/rtw_recv.c | 41 ----- drivers/staging/rtl8188eu/core/rtw_security.c | 75 +-------- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 28 +--- .../staging/rtl8188eu/core/rtw_wlan_util.c | 2 - drivers/staging/rtl8188eu/core/rtw_xmit.c | 49 +----- drivers/staging/rtl8188eu/hal/hal_intf.c | 4 - drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 12 -- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 2 - .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 - drivers/staging/rtl8188eu/hal/usb_halinit.c | 10 -- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 23 +-- drivers/staging/rtl8188eu/include/rtw_debug.h | 14 -- drivers/staging/rtl8188eu/include/rtw_ioctl.h | 2 - .../staging/rtl8188eu/os_dep/ioctl_linux.c | 58 ------- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 9 +- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 3 - drivers/staging/rtl8188eu/os_dep/usb_intf.c | 14 -- .../staging/rtl8188eu/os_dep/usb_ops_linux.c | 5 - drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 9 - 29 files changed, 16 insertions(+), 809 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index cc322e5b0d6c..bc7873604a89 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -36,7 +36,6 @@ int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) { int res = _SUCCESS; -_func_enter_; sema_init(&(pcmdpriv->cmd_queue_sema), 0); /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ @@ -71,7 +70,6 @@ _func_enter_; pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; exit: -_func_exit_; return res; } @@ -81,7 +79,6 @@ int _rtw_init_evt_priv(struct evt_priv *pevtpriv) { int res = _SUCCESS; -_func_enter_; /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ atomic_set(&pevtpriv->event_seq, 0); @@ -91,14 +88,12 @@ _func_enter_; pevtpriv->c2h_wk_alive = false; pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); -_func_exit_; return res; } void rtw_free_evt_priv(struct evt_priv *pevtpriv) { -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+rtw_free_evt_priv\n")); @@ -113,12 +108,10 @@ _func_enter_; } RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-rtw_free_evt_priv\n")); -_func_exit_; } void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) { -_func_enter_; if (pcmdpriv) { if (pcmdpriv->cmd_allocated_buf) @@ -127,7 +120,6 @@ _func_enter_; if (pcmdpriv->rsp_allocated_buf) kfree(pcmdpriv->rsp_allocated_buf); } -_func_exit_; } /* @@ -144,7 +136,6 @@ int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) { unsigned long irqL; -_func_enter_; if (obj == NULL) goto exit; @@ -157,7 +148,6 @@ _func_enter_; exit: -_func_exit_; return _SUCCESS; } @@ -167,7 +157,6 @@ struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) unsigned long irqL; struct cmd_obj *obj; -_func_enter_; spin_lock_irqsave(&queue->lock, irqL); if (rtw_is_list_empty(&(queue->queue))) { @@ -179,7 +168,6 @@ _func_enter_; spin_unlock_irqrestore(&queue->lock, irqL); -_func_exit_; return obj; } @@ -187,27 +175,21 @@ _func_exit_; u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { u32 res; -_func_enter_; res = _rtw_init_cmd_priv (pcmdpriv); -_func_exit_; return res; } u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) { int res; -_func_enter_; res = _rtw_init_evt_priv(pevtpriv); -_func_exit_; return res; } void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) { -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); _rtw_free_cmd_priv(pcmdpriv); -_func_exit_; } static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) @@ -238,7 +220,6 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) int res = _FAIL; struct adapter *padapter = pcmdpriv->padapter; -_func_enter_; if (cmd_obj == NULL) goto exit; @@ -258,7 +239,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -267,25 +247,20 @@ struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) { struct cmd_obj *cmd_obj; -_func_enter_; cmd_obj = _rtw_dequeue_cmd(&pcmdpriv->cmd_queue); -_func_exit_; return cmd_obj; } void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv) { -_func_enter_; pcmdpriv->cmd_done_cnt++; /* up(&(pcmdpriv->cmd_done_sema)); */ -_func_exit_; } void rtw_free_cmd_obj(struct cmd_obj *pcmd) { -_func_enter_; if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) { /* free parmbuf in cmd_obj */ @@ -302,7 +277,6 @@ _func_enter_; /* free cmd_obj */ kfree(pcmd); -_func_exit_; } int rtw_cmd_thread(void *context) @@ -315,7 +289,6 @@ int rtw_cmd_thread(void *context) struct adapter *padapter = (struct adapter *)context; struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); -_func_enter_; thread_enter("RTW_CMD_THREAD"); @@ -410,7 +383,6 @@ post_process: up(&pcmdpriv->terminate_cmdthread_sema); -_func_exit_; complete_and_exit(NULL, 0); } @@ -423,7 +395,6 @@ u8 rtw_setstandby_cmd(struct adapter *padapter, uint action) u8 ret = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -446,7 +417,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -465,7 +435,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); } @@ -537,7 +506,6 @@ _func_enter_; _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } -_func_exit_; return res; } @@ -549,7 +517,6 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -570,7 +537,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -582,7 +548,6 @@ u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -604,7 +569,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -624,7 +588,6 @@ u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -648,7 +611,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -659,7 +621,6 @@ u8 rtw_setbbreg_cmd(struct adapter *padapter, u8 offset, u8 val) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; @@ -680,7 +641,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -691,7 +651,6 @@ u8 rtw_getbbreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; @@ -715,7 +674,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -725,7 +683,6 @@ u8 rtw_setrfreg_cmd(struct adapter *padapter, u8 offset, u32 val) struct writeRF_parm *pwriterfparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; @@ -746,7 +703,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -757,7 +713,6 @@ u8 rtw_getrfreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -785,33 +740,28 @@ _func_enter_; exit: -_func_exit_; return res; } void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { - _func_enter_; kfree(pcmd->parmbuf); kfree(pcmd); if (padapter->registrypriv.mp_mode == 1) padapter->mppriv.workparam.bcompleted = true; -_func_exit_; } void rtw_readtssi_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { - _func_enter_; kfree(pcmd->parmbuf); kfree(pcmd); if (padapter->registrypriv.mp_mode == 1) padapter->mppriv.workparam.bcompleted = true; -_func_exit_; } u8 rtw_createbss_cmd(struct adapter *padapter) @@ -822,7 +772,6 @@ u8 rtw_createbss_cmd(struct adapter *padapter) struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; u8 res = _SUCCESS; -_func_enter_; rtw_led_control(padapter, LED_CTL_START_TO_LINK); @@ -847,7 +796,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: -_func_exit_; return res; } @@ -858,7 +806,6 @@ u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, unsigned struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { @@ -877,7 +824,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -898,7 +844,6 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -_func_enter_; rtw_led_control(padapter, LED_CTL_START_TO_LINK); @@ -1020,7 +965,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1032,7 +976,6 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu struct cmd_priv *cmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); @@ -1063,7 +1006,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1076,7 +1018,6 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra n struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1098,7 +1039,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1115,7 +1055,6 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) struct sta_info *sta = (struct sta_info *)psta; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1161,7 +1100,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1175,7 +1113,6 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) struct sta_info *sta = (struct sta_info *)psta; u8 res = _SUCCESS; -_func_enter_; if (!enqueue) { clear_cam_entry(padapter, entry); @@ -1215,7 +1152,6 @@ _func_enter_; } exit: -_func_exit_; return res; } @@ -1226,7 +1162,6 @@ u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_tab struct setratable_parm *psetrttblparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1247,7 +1182,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -1257,7 +1191,6 @@ u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval) struct getratable_parm *pgetrttblparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1285,7 +1218,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -1298,7 +1230,6 @@ u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr) u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1330,7 +1261,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1342,7 +1272,6 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) struct addBaReq_parm *paddbareq_parm; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1369,7 +1298,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1381,7 +1309,6 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -1406,7 +1333,6 @@ _func_enter_; /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -1418,7 +1344,6 @@ u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enque u8 res = _SUCCESS; -_func_enter_; DBG_88E(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), ch, bw, ch_offset); @@ -1460,7 +1385,6 @@ exit: DBG_88E(FUNC_NDEV_FMT" res:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), res); -_func_exit_; return res; } @@ -1473,7 +1397,6 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) u8 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n")); @@ -1516,7 +1439,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1529,7 +1451,6 @@ u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) u8 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); @@ -1553,7 +1474,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1566,7 +1486,6 @@ u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) u8 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_csa_cmd\n")); @@ -1590,7 +1509,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1685,7 +1603,6 @@ static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); u8 mstatus; -_func_enter_; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) @@ -1724,7 +1641,6 @@ _func_enter_; break; } -_func_exit_; } u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) @@ -1735,7 +1651,6 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) /* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */ u8 res = _SUCCESS; -_func_enter_; /* if (!pwrctrlpriv->bLeisurePs) */ /* return res; */ @@ -1767,7 +1682,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1785,7 +1699,6 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) u8 res = _SUCCESS; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; @@ -1806,7 +1719,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -1824,7 +1736,6 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) u8 support_ant_div; u8 res = _SUCCESS; -_func_enter_; rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); if (!support_ant_div) return res; @@ -1854,7 +1765,6 @@ _func_enter_; } exit: -_func_exit_; return res; } @@ -1873,7 +1783,6 @@ u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) return res; @@ -1901,7 +1810,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1914,7 +1822,6 @@ u8 rtw_ps_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; ppscmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ppscmd == NULL) { @@ -1937,7 +1844,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -2174,7 +2080,6 @@ void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (pcmd->res == H2C_DROPPED) { /* TODO: cancel timer and do timeout handler directly... */ @@ -2188,13 +2093,11 @@ _func_enter_; /* free cmd */ rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (pcmd->res != H2C_SUCCESS) { spin_lock_bh(&pmlmepriv->lock); @@ -2202,24 +2105,18 @@ _func_enter_; spin_unlock_bh(&pmlmepriv->lock); RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ***Error: disconnect_cmd_callback Fail ***\n.")); - - goto exit; + return; } else /* clear bridge database */ nat25_db_cleanup(padapter); /* free cmd */ rtw_free_cmd_obj(pcmd); - -exit: - -_func_exit_; } void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (pcmd->res == H2C_DROPPED) { /* TODO: cancel timer and do timeout handler directly... */ @@ -2232,7 +2129,6 @@ _func_enter_; rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) @@ -2244,7 +2140,6 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; struct wlan_network *tgt_network = &(pmlmepriv->cur_network); -_func_enter_; if ((pcmd->res != H2C_SUCCESS)) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n.")); @@ -2298,7 +2193,6 @@ createbss_cmd_fail: rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) @@ -2307,7 +2201,6 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); -_func_enter_; if (psta == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); @@ -2315,7 +2208,6 @@ _func_enter_; } exit: rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) @@ -2326,7 +2218,6 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj * struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); -_func_enter_; if (psta == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); @@ -2347,5 +2238,4 @@ _func_enter_; exit: rtw_free_cmd_obj(pcmd); -_func_exit_; } diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 002195acb5d5..d779c805b8a8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -147,7 +147,6 @@ u8 *rtw_set_ie uint *frlen /* frame length */ ) { -_func_enter_; *pbuf = (u8)index; *(pbuf + 1) = (u8)len; @@ -157,7 +156,6 @@ _func_enter_; *frlen = *frlen + (len + 2); -_func_exit_; return pbuf + len + 2; } @@ -221,9 +219,7 @@ u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit) { int tmp, i; u8 *p; -_func_enter_; if (limit < 1) { - _func_exit_; return NULL; } @@ -242,7 +238,6 @@ _func_enter_; if (i >= limit) break; } -_func_exit_; return NULL; } @@ -339,7 +334,6 @@ exit: void rtw_set_supported_rate(u8 *SupportedRates, uint mode) { -_func_enter_; _rtw_memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); @@ -361,13 +355,11 @@ _func_enter_; memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); break; } -_func_exit_; } uint rtw_get_rateset_len(u8 *rateset) { uint i = 0; -_func_enter_; while (1) { if ((rateset[i]) == 0) break; @@ -375,7 +367,6 @@ _func_enter_; break; i++; } -_func_exit_; return i; } @@ -386,7 +377,6 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *ie = pdev_network->IEs; -_func_enter_; /* timestamp will be inserted by hardware */ sz += 8; @@ -444,7 +434,6 @@ _func_enter_; if (rateLen > 8) ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); -_func_exit_; return sz; } @@ -672,7 +661,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; -_func_enter_; /* Search required WPA or WPA2 IE and copy to sec_ie[] */ @@ -726,7 +714,6 @@ _func_enter_; } } -_func_exit_; return *rsn_len + *wpa_len; } diff --git a/drivers/staging/rtl8188eu/core/rtw_io.c b/drivers/staging/rtl8188eu/core/rtw_io.c index ff0398fca52b..7530532b3ff0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_io.c +++ b/drivers/staging/rtl8188eu/core/rtw_io.c @@ -59,10 +59,8 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr) struct intf_hdl *pintfhdl = &(pio_priv->intf); u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); - _func_enter_; _read8 = pintfhdl->io_ops._read8; r_val = _read8(pintfhdl, addr); - _func_exit_; return r_val; } @@ -72,11 +70,9 @@ u16 _rtw_read16(struct adapter *adapter, u32 addr) struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); -_func_enter_; _read16 = pintfhdl->io_ops._read16; r_val = _read16(pintfhdl, addr); -_func_exit_; return r_val; } @@ -86,11 +82,9 @@ u32 _rtw_read32(struct adapter *adapter, u32 addr) struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); -_func_enter_; _read32 = pintfhdl->io_ops._read32; r_val = _read32(pintfhdl, addr); -_func_exit_; return r_val; } @@ -100,11 +94,9 @@ int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) struct intf_hdl *pintfhdl = &(pio_priv->intf); int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); int ret; - _func_enter_; _write8 = pintfhdl->io_ops._write8; ret = _write8(pintfhdl, addr, val); - _func_exit_; return RTW_STATUS_CODE(ret); } @@ -115,11 +107,9 @@ int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) struct intf_hdl *pintfhdl = &(pio_priv->intf); int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int ret; - _func_enter_; _write16 = pintfhdl->io_ops._write16; ret = _write16(pintfhdl, addr, val); - _func_exit_; return RTW_STATUS_CODE(ret); } @@ -129,11 +119,9 @@ int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) struct intf_hdl *pintfhdl = &(pio_priv->intf); int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int ret; - _func_enter_; _write32 = pintfhdl->io_ops._write32; ret = _write32(pintfhdl, addr, val); - _func_exit_; return RTW_STATUS_CODE(ret); } @@ -144,11 +132,9 @@ int _rtw_writeN(struct adapter *adapter, u32 addr , u32 length , u8 *pdata) struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_priv->intf)); int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); int ret; - _func_enter_; _writeN = pintfhdl->io_ops._writeN; ret = _writeN(pintfhdl, addr, length, pdata); - _func_exit_; return RTW_STATUS_CODE(ret); } @@ -158,11 +144,9 @@ int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) struct intf_hdl *pintfhdl = &(pio_priv->intf); int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); int ret; - _func_enter_; _write8_async = pintfhdl->io_ops._write8_async; ret = _write8_async(pintfhdl, addr, val); - _func_exit_; return RTW_STATUS_CODE(ret); } @@ -174,10 +158,8 @@ int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int ret; -_func_enter_; _write16_async = pintfhdl->io_ops._write16_async; ret = _write16_async(pintfhdl, addr, val); -_func_exit_; return RTW_STATUS_CODE(ret); } @@ -189,10 +171,8 @@ int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val) int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int ret; -_func_enter_; _write32_async = pintfhdl->io_ops._write32_async; ret = _write32_async(pintfhdl, addr, val); -_func_exit_; return RTW_STATUS_CODE(ret); } @@ -203,7 +183,6 @@ void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); - _func_enter_; if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", @@ -212,7 +191,6 @@ void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) } _read_mem = pintfhdl->io_ops._read_mem; _read_mem(pintfhdl, addr, cnt, pmem); - _func_exit_; } void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) @@ -221,13 +199,11 @@ void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); - _func_enter_; _write_mem = pintfhdl->io_ops._write_mem; _write_mem(pintfhdl, addr, cnt, pmem); - _func_exit_; } void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) @@ -236,7 +212,6 @@ void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); - _func_enter_; if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { RT_TRACE(_module_rtl871x_io_c_, _drv_info_, @@ -249,7 +224,6 @@ void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) _read_port(pintfhdl, addr, cnt, pmem); - _func_exit_; } void _rtw_read_port_cancel(struct adapter *adapter) @@ -271,13 +245,11 @@ u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) struct intf_hdl *pintfhdl = &(pio_priv->intf); u32 ret = _SUCCESS; - _func_enter_; _write_port = pintfhdl->io_ops._write_port; ret = _write_port(pintfhdl, addr, cnt, pmem); - _func_exit_; return ret; } diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 0f0f515b0596..807b7d4befff 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -42,7 +42,6 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) u8 i; u8 ret = true; -_func_enter_; if (ssid->SsidLength > 32) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); @@ -61,8 +60,6 @@ _func_enter_; exit: -_func_exit_; - return ret; } @@ -74,7 +71,6 @@ u8 rtw_do_join(struct adapter *padapter) struct __queue *queue = &(pmlmepriv->scanned_queue); u8 ret = _SUCCESS; -_func_enter_; spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); @@ -170,7 +166,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -181,7 +176,6 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; DBG_88E_LEVEL(_drv_info_, "set bssid:%pM\n", bssid); @@ -257,7 +251,6 @@ exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid: status=%d\n", status)); -_func_exit_; return status; } @@ -270,7 +263,6 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; -_func_enter_; DBG_88E_LEVEL(_drv_info_, "set ssid [%s] fw_state=0x%08x\n", ssid->Ssid, get_fwstate(pmlmepriv)); @@ -369,7 +361,6 @@ release_mlme_lock: exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("-rtw_set_802_11_ssid: status =%d\n", status)); -_func_exit_; return status; } @@ -380,7 +371,6 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, struct wlan_network *cur_network = &pmlmepriv->cur_network; enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); -_func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", @@ -438,7 +428,6 @@ _func_enter_; spin_unlock_bh(&pmlmepriv->lock); } -_func_exit_; return true; } @@ -448,7 +437,6 @@ u8 rtw_set_802_11_disassociate(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; spin_lock_bh(&pmlmepriv->lock); @@ -464,7 +452,6 @@ _func_enter_; spin_unlock_bh(&pmlmepriv->lock); -_func_exit_; return true; } @@ -474,7 +461,6 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 res = true; -_func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); @@ -514,7 +500,6 @@ _func_enter_; } exit: -_func_exit_; return res; } @@ -525,7 +510,6 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 int res; u8 ret; -_func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); @@ -545,7 +529,6 @@ _func_enter_; else ret = false; -_func_exit_; return ret; } @@ -556,7 +539,6 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) struct security_priv *psecuritypriv = &(padapter->securitypriv); u8 ret = _SUCCESS; -_func_enter_; keyid = wep->KeyIndex & 0x3fffffff; @@ -611,7 +593,6 @@ _func_enter_; if (res == _FAIL) ret = false; exit: -_func_exit_; return ret; } @@ -619,7 +600,6 @@ u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) { u8 ret = _SUCCESS; -_func_enter_; if (keyindex >= 0x80000000 || padapter == NULL) { ret = false; goto exit; @@ -638,7 +618,6 @@ _func_enter_; } exit: -_func_exit_; return ret; } @@ -651,7 +630,6 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) u8 bgrouptkey = false;/* can be removed later */ u8 ret = _SUCCESS; -_func_enter_; if (((key->KeyIndex & 0x80000000) == 0) && ((key->KeyIndex & 0x40000000) > 0)) { /* It is invalid to clear bit 31 and set bit 30. If the miniport driver encounters this combination, */ @@ -992,7 +970,6 @@ _func_enter_; } exit: -_func_exit_; return ret; } @@ -1004,7 +981,6 @@ u8 rtw_set_802_11_remove_key(struct adapter *padapter, struct ndis_802_11_remove u8 keyIndex = (u8)key->KeyIndex & 0x03; u8 ret = _SUCCESS; -_func_enter_; if ((key->KeyIndex & 0xbffffffc) > 0) { ret = _FAIL; @@ -1032,7 +1008,6 @@ _func_enter_; } exit: -_func_exit_; return ret; } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 700a34d73c2d..260da41cfd46 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -44,8 +44,6 @@ int _rtw_init_mlme_priv (struct adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int res = _SUCCESS; -_func_enter_; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ pmlmepriv->nic_hdl = (u8 *)padapter; @@ -88,9 +86,6 @@ _func_enter_; rtw_init_mlme_timer(padapter); exit: - -_func_exit_; - return res; } @@ -125,21 +120,16 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) { -_func_enter_; - rtw_free_mlme_priv_ie_data(pmlmepriv); if (pmlmepriv) { if (pmlmepriv->free_bss_buf) vfree(pmlmepriv->free_bss_buf); } -_func_exit_; } int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork) { -_func_enter_; - if (pnetwork == NULL) goto exit; @@ -150,9 +140,6 @@ _func_enter_; spin_unlock_bh(&queue->lock); exit: - -_func_exit_; - return _SUCCESS; } @@ -160,8 +147,6 @@ struct wlan_network *_rtw_dequeue_network(struct __queue *queue) { struct wlan_network *pnetwork; -_func_enter_; - spin_lock_bh(&queue->lock); if (_rtw_queue_empty(queue)) { @@ -174,8 +159,6 @@ _func_enter_; spin_unlock_bh(&queue->lock); -_func_exit_; - return pnetwork; } @@ -185,8 +168,6 @@ struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *f struct __queue *free_queue = &pmlmepriv->free_bss_pool; struct list_head *plist = NULL; -_func_enter_; - spin_lock_bh(&free_queue->lock); if (_rtw_queue_empty(free_queue) == true) { @@ -211,8 +192,6 @@ _func_enter_; exit: spin_unlock_bh(&free_queue->lock); -_func_exit_; - return pnetwork; } @@ -222,13 +201,11 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwo u32 lifetime = SCANQUEUE_LIFETIME; struct __queue *free_queue = &(pmlmepriv->free_bss_pool); -_func_enter_; - if (pnetwork == NULL) - goto exit; + return; if (pnetwork->fixed) - goto exit; + return; curr_time = jiffies; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) @@ -236,33 +213,26 @@ _func_enter_; if (!isfreeall) { delta_time = (curr_time - pnetwork->last_scanned)/HZ; if (delta_time < lifetime)/* unit:sec */ - goto exit; + return; } spin_lock_bh(&free_queue->lock); rtw_list_delete(&(pnetwork->list)); rtw_list_insert_tail(&(pnetwork->list), &(free_queue->queue)); pmlmepriv->num_of_scanned--; spin_unlock_bh(&free_queue->lock); - -exit: -_func_exit_; } void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { struct __queue *free_queue = &(pmlmepriv->free_bss_pool); -_func_enter_; if (pnetwork == NULL) - goto exit; + return; if (pnetwork->fixed) - goto exit; + return; rtw_list_delete(&(pnetwork->list)); rtw_list_insert_tail(&(pnetwork->list), get_list_head(free_queue)); pmlmepriv->num_of_scanned--; -exit: - -_func_exit_; } /* @@ -276,7 +246,6 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) struct wlan_network *pnetwork = NULL; u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; -_func_enter_; if (!memcmp(zero_addr, addr, ETH_ALEN)) { pnetwork = NULL; goto exit; @@ -293,7 +262,6 @@ _func_enter_; if (plist == phead) pnetwork = NULL; exit: -_func_exit_; return pnetwork; } @@ -305,9 +273,6 @@ void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *scanned_queue = &pmlmepriv->scanned_queue; -_func_enter_; - - spin_lock_bh(&scanned_queue->lock); phead = get_list_head(scanned_queue); @@ -321,13 +286,11 @@ _func_enter_; _rtw_free_network(pmlmepriv, pnetwork, isfreeall); } spin_unlock_bh(&scanned_queue->lock); -_func_exit_; } int rtw_if_up(struct adapter *padapter) { int res; -_func_enter_; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { @@ -338,8 +301,6 @@ _func_enter_; } else { res = true; } - -_func_exit_; return res; } @@ -347,14 +308,12 @@ void rtw_generate_random_ibss(u8 *pibss) { u32 curtime = jiffies; -_func_enter_; pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ -_func_exit_; return; } @@ -367,11 +326,9 @@ u8 *rtw_get_capability_from_ie(u8 *ie) u16 rtw_get_capability(struct wlan_bssid_ex *bss) { __le16 val; -_func_enter_; memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2); -_func_exit_; return le16_to_cpu(val); } @@ -388,43 +345,31 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie) int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ { int res; -_func_enter_; res = _rtw_init_mlme_priv(padapter);/* (pmlmepriv); */ -_func_exit_; return res; } void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) { -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); _rtw_free_mlme_priv (pmlmepriv); -_func_exit_; } static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) { - struct wlan_network *pnetwork; -_func_enter_; - pnetwork = _rtw_alloc_network(pmlmepriv); -_func_exit_; - return pnetwork; + return _rtw_alloc_network(pmlmepriv); } static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { -_func_enter_; _rtw_free_network_nolock(pmlmepriv, pnetwork); -_func_exit_; } void rtw_free_network_queue(struct adapter *dev, u8 isfreeall) { -_func_enter_; _rtw_free_network_queue(dev, isfreeall); -_func_exit_; } /* @@ -466,7 +411,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) u16 s_cap, d_cap; __le16 le_scap, le_dcap; -_func_enter_; memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->IEs), 2); memcpy((u8 *)&le_dcap, rtw_get_capability_from_ie(dst->IEs), 2); @@ -474,8 +418,6 @@ _func_enter_; s_cap = le16_to_cpu(le_scap); d_cap = le16_to_cpu(le_dcap); -_func_exit_; - return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && @@ -491,7 +433,6 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) struct wlan_network *pwlan = NULL; struct wlan_network *oldest = NULL; -_func_enter_; phead = get_list_head(scanned_queue); plist = phead->next; @@ -509,7 +450,6 @@ _func_enter_; plist = plist->next; } -_func_exit_; return oldest; } @@ -522,7 +462,6 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 sq_final; long rssi_final; -_func_enter_; rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ /* The rule below is 1/5 for sample value, 4/5 for history value */ @@ -553,22 +492,18 @@ _func_enter_; dst->PhyInfo.SignalQuality = sq_final; dst->Rssi = rssi_final; -_func_exit_; } static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); -_func_enter_; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork))) { update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), pmlmepriv->cur_network.network.IELength); } -_func_exit_; } /* @@ -583,8 +518,6 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t struct wlan_network *pnetwork = NULL; struct wlan_network *oldest = NULL; -_func_enter_; - spin_lock_bh(&queue->lock); phead = get_list_head(queue); plist = phead->next; @@ -663,19 +596,16 @@ _func_enter_; exit: spin_unlock_bh(&queue->lock); -_func_exit_; } static void rtw_add_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { -_func_enter_; #if defined(CONFIG_88EU_P2P) rtw_wlan_bssid_ex_remove_p2p_attr(pnetwork, P2P_ATTR_GROUP_INFO); #endif update_current_network(adapter, pnetwork); rtw_update_scanned_network(adapter, pnetwork); -_func_exit_; } /* select the desired network based on the capability of the (i)bss. */ @@ -728,9 +658,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * /* TODO: Perry: For Power Management */ void rtw_atimdone_event_callback(struct adapter *adapter , u8 *pbuf) { -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); -_func_exit_; return; } @@ -741,8 +669,6 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) struct wlan_bssid_ex *pnetwork; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); -_func_enter_; - pnetwork = (struct wlan_bssid_ex *)pbuf; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid=%s\n", pnetwork->Ssid.Ssid)); @@ -781,20 +707,14 @@ _func_enter_; exit: spin_unlock_bh(&pmlmepriv->lock); - -_func_exit_; - return; } - - void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct mlme_ext_priv *pmlmeext; -_func_enter_; spin_lock_bh(&pmlmepriv->lock); if (pmlmepriv->wps_probe_req_ie) { @@ -884,7 +804,6 @@ _func_enter_; pmlmeext = &adapter->mlmeextpriv; if (pmlmeext->sitesurvey_res.bss_cnt == 0) rtw_hal_sreset_reset(adapter); -_func_exit_; } void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) @@ -901,8 +820,6 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) struct __queue *scan_queue = &pmlmepriv->scanned_queue; struct list_head *plist, *phead, *ptemp; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); spin_lock_bh(&scan_queue->lock); spin_lock_bh(&free_queue->lock); @@ -920,8 +837,6 @@ _func_enter_; spin_unlock_bh(&free_queue->lock); spin_unlock_bh(&scan_queue->lock); - -_func_exit_; } /* @@ -934,8 +849,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress=%pM ssid=%s\n", @@ -979,7 +892,6 @@ _func_enter_; if (lock_scanned_queue) spin_unlock_bh(&pmlmepriv->scanned_queue.lock); pmlmepriv->key_mask = 0; -_func_exit_; } /* @@ -989,8 +901,6 @@ void rtw_indicate_connect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect\n")); pmlmepriv->to_join = false; @@ -1008,7 +918,6 @@ _func_enter_; rtw_set_scan_deny(padapter, 3000); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); -_func_exit_; } /* @@ -1018,7 +927,6 @@ void rtw_indicate_disconnect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n")); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); @@ -1038,8 +946,6 @@ _func_enter_; p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1); - -_func_exit_; } inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) @@ -1206,8 +1112,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; unsigned int the_same_macaddr = false; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res=%d\n", pnetwork->join_res)); rtw_get_encrypt_decrypt_from_registrypriv(adapter); @@ -1223,7 +1127,7 @@ _func_enter_; pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); - goto ignore_nolock; + return; } spin_lock_bh(&pmlmepriv->lock); @@ -1319,21 +1223,15 @@ _func_enter_; ignore_joinbss_callback: spin_unlock_bh(&pmlmepriv->lock); -ignore_nolock: -_func_exit_; } void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) { struct wlan_network *pnetwork = (struct wlan_network *)pbuf; -_func_enter_; - mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); rtw_os_xmit_schedule(adapter); - -_func_exit_; } static u8 search_max_mac_id(struct adapter *padapter) @@ -1388,8 +1286,6 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) struct wlan_network *cur_network = &(pmlmepriv->cur_network); struct wlan_network *ptarget_wlan = NULL; -_func_enter_; - if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) return; @@ -1400,7 +1296,7 @@ _func_enter_; ap_sta_info_defer_update(adapter, psta); rtw_stassoc_hw_rpt(adapter, psta); } - goto exit; + return; } #endif /* for AD-HOC mode */ @@ -1408,12 +1304,12 @@ _func_enter_; if (psta != NULL) { /* the sta have been in sta_info_queue => do nothing */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); - goto exit; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ } psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta == NULL) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); - goto exit; + return; } /* to do: init sta_info variable */ psta->qos_option = 0; @@ -1440,8 +1336,6 @@ _func_enter_; } spin_unlock_bh(&pmlmepriv->lock); mlmeext_sta_add_event_callback(adapter, psta); -exit: -_func_exit_; } void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) @@ -1456,8 +1350,6 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &(pmlmepriv->cur_network); -_func_enter_; - psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); if (psta) mac_id = psta->mac_id; @@ -1541,14 +1433,11 @@ _func_enter_; } } spin_unlock_bh(&pmlmepriv->lock); -_func_exit_; } void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) { -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); -_func_exit_; } /* @@ -1560,8 +1449,6 @@ void _rtw_join_timeout_handler (struct adapter *adapter) struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int do_join_r; -_func_enter_; - DBG_88E("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); if (adapter->bDriverStopped || adapter->bSurpriseRemoved) @@ -1592,7 +1479,6 @@ _func_enter_; free_scanqueue(pmlmepriv);/* */ } spin_unlock_bh(&pmlmepriv->lock); -_func_exit_; } /* @@ -1742,8 +1628,6 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) struct wlan_network *candidate = NULL; u8 supp_ant_div = false; -_func_enter_; - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); adapter = (struct adapter *)pmlmepriv->nic_hdl; @@ -1792,9 +1676,6 @@ _func_enter_; exit: spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - -_func_exit_; - return ret; } @@ -1805,8 +1686,6 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); int res = _SUCCESS; -_func_enter_; - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; /* try again */ @@ -1832,7 +1711,6 @@ _func_enter_; psecuritypriv->dot11AuthAlgrthm)); res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: -_func_exit_; return res; } @@ -1845,7 +1723,6 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); int res = _SUCCESS; -_func_enter_; pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; /* try again */ @@ -1914,7 +1791,6 @@ _func_enter_; _rtw_init_listhead(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: -_func_exit_; return res; } @@ -2018,8 +1894,6 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ uint ndisauthmode = psecuritypriv->ndisauthtype; uint ndissecuritytype = psecuritypriv->ndisencryptstatus; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_restruct_sec_ie: ndisauthmode=%d ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype)); @@ -2052,9 +1926,6 @@ _func_enter_; if (authmode == _WPA2_IE_ID_) ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); } - -_func_exit_; - return ielength; } @@ -2065,8 +1936,6 @@ void rtw_init_registrypriv_dev_network(struct adapter *adapter) struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *myhwaddr = myid(peepriv); -_func_enter_; - memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); @@ -2077,8 +1946,6 @@ _func_enter_; pdev_network->Configuration.FHConfig.HopPattern = 0; pdev_network->Configuration.FHConfig.HopSet = 0; pdev_network->Configuration.FHConfig.DwellTime = 0; - -_func_exit_; } void rtw_update_registrypriv_dev_network(struct adapter *adapter) @@ -2089,8 +1956,6 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) struct security_priv *psecuritypriv = &adapter->securitypriv; struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; -_func_enter_; - pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /* adhoc no 802.1x */ pdev_network->Rssi = 0; @@ -2140,13 +2005,10 @@ _func_enter_; /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ /* pdev_network->IELength = cpu_to_le32(sz); */ -_func_exit_; } void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) { -_func_enter_; -_func_exit_; } /* the function is at passive_level */ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 2c5d704b0a4d..b84610f8f58f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -8265,7 +8265,6 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) u8 res = _SUCCESS; int len_diff = 0; -_func_enter_; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { @@ -8294,7 +8293,6 @@ _func_enter_; exit: -_func_exit_; return res; } diff --git a/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c b/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c index edcd8a5042be..e783968b29ea 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c @@ -33,7 +33,6 @@ int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->information_buf_len < sizeof(u8)) return NDIS_STATUS_INVALID_LENGTH; @@ -48,7 +47,6 @@ _func_enter_; status = NDIS_STATUS_NOT_ACCEPTED; } -_func_exit_; return status; } @@ -61,7 +59,6 @@ int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_bb_reg_hdl\n")); @@ -87,7 +84,6 @@ _func_enter_; write_bbreg(Adapter, offset, 0xFFFFFFFF, value); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -100,7 +96,6 @@ int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_bb_reg_hdl\n")); @@ -126,7 +121,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", offset, value)); -_func_exit_; return status; } @@ -140,7 +134,6 @@ int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_rf_reg_hdl\n")); @@ -171,7 +164,6 @@ _func_enter_; write_rfreg(Adapter, path, offset, value); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -185,7 +177,6 @@ int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); int status = NDIS_STATUS_SUCCESS; -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_rf_reg_hdl\n")); @@ -217,7 +208,6 @@ _func_enter_; ("-rtl8188eu_oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", path, offset, value)); -_func_exit_; return status; } @@ -232,7 +222,6 @@ int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n")); @@ -255,7 +244,6 @@ _func_enter_; SetDataRate(Adapter); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -266,7 +254,6 @@ int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_start_test_hdl\n")); @@ -293,7 +280,6 @@ exit: RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); -_func_exit_; return status; } @@ -303,7 +289,6 @@ int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+Set OID_RT_PRO_STOP_TEST\n")); @@ -316,7 +301,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n")); -_func_exit_; return status; } @@ -327,7 +311,6 @@ int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_p int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n")); @@ -352,7 +335,6 @@ _func_enter_; SetChannel(Adapter); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -364,7 +346,6 @@ int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_set_bandwidth_hdl\n")); @@ -391,7 +372,6 @@ _func_enter_; ("-rtl8188eu_oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", bandwidth, channel_offset)); -_func_exit_; return status; } @@ -402,7 +382,6 @@ int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_antenna_bb_hdl\n")); @@ -426,7 +405,6 @@ _func_enter_; *(u32 *)poid_par_priv->information_buf = antenna; } -_func_exit_; return status; } @@ -437,7 +415,6 @@ int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_ int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_set_tx_power_control_hdl\n")); @@ -461,7 +438,6 @@ _func_enter_; SetTxPower(Adapter); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -474,7 +450,6 @@ int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_ int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != QUERY_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -488,7 +463,6 @@ _func_enter_; status = NDIS_STATUS_INVALID_LENGTH; } -_func_exit_; return status; } @@ -498,7 +472,6 @@ int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_ int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != QUERY_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -513,7 +486,6 @@ _func_enter_; status = NDIS_STATUS_INVALID_LENGTH; } -_func_exit_; return status; } @@ -523,7 +495,6 @@ int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *po int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != QUERY_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -538,7 +509,6 @@ _func_enter_; status = NDIS_STATUS_INVALID_LENGTH; } -_func_exit_; return status; } @@ -549,7 +519,6 @@ int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_ int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != SET_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -559,7 +528,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl.\n")); Adapter->mppriv.tx_pktcount = 0; -_func_exit_; return status; } @@ -569,7 +537,6 @@ int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_ int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != SET_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -583,7 +550,6 @@ _func_enter_; status = NDIS_STATUS_INVALID_LENGTH; } -_func_exit_; return status; } @@ -593,7 +559,6 @@ int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != SET_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -604,7 +569,6 @@ _func_enter_; ResetPhyRxPktCount(Adapter); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -614,7 +578,6 @@ int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_pa int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl\n")); @@ -632,7 +595,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); -_func_exit_; return status; } @@ -642,7 +604,6 @@ int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); @@ -663,7 +624,6 @@ _func_enter_; ("-rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", *(u32 *)poid_par_priv->information_buf)); -_func_exit_; return status; } @@ -674,7 +634,6 @@ int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_pri int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_continuous_tx_hdl\n")); @@ -698,7 +657,6 @@ _func_enter_; } _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -709,7 +667,6 @@ int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl\n")); @@ -733,7 +690,6 @@ _func_enter_; } _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -744,7 +700,6 @@ int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poi int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl\n")); @@ -768,7 +723,6 @@ _func_enter_; } _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -779,7 +733,6 @@ int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_pr int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl\n")); @@ -792,7 +745,6 @@ _func_enter_; SetSingleToneTx(Adapter, (u8)bStartTest); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -806,7 +758,6 @@ int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv) { struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); int status = NDIS_STATUS_SUCCESS; -_func_enter_; if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -815,7 +766,6 @@ _func_enter_; rtw_hal_set_hwreg(Adapter, HW_VAR_TRIGGER_GPIO_0, NULL); _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -833,7 +783,6 @@ int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_read_register_hdl\n")); @@ -870,7 +819,6 @@ _func_enter_; *poid_par_priv->bytes_rw = width; -_func_exit_; return status; } @@ -882,7 +830,6 @@ int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_write_register_hdl\n")); @@ -929,7 +876,6 @@ _func_enter_; ("-rtl8188eu_oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", offset, width, value)); -_func_exit_; return status; } @@ -1002,7 +948,6 @@ int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv int status = NDIS_STATUS_SUCCESS; -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+OID_RT_PRO_SET_DATA_RATE_EX\n")); @@ -1016,7 +961,6 @@ _func_enter_; _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -1027,7 +971,6 @@ int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) u8 thermal = 0; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_get_thermal_meter_hdl\n")); @@ -1044,7 +987,6 @@ _func_enter_; *(u32 *)poid_par_priv->information_buf = (u32)thermal; *poid_par_priv->bytes_rw = sizeof(u32); -_func_exit_; return status; } @@ -1060,7 +1002,6 @@ int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_pr struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->information_buf_len < sizeof(u8)) return NDIS_STATUS_INVALID_LENGTH; @@ -1079,7 +1020,6 @@ _func_enter_; } _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -1143,7 +1083,6 @@ int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1176,7 +1115,6 @@ _func_enter_; } _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -1190,7 +1128,6 @@ int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1216,7 +1153,6 @@ _func_enter_; status = NDIS_STATUS_FAILURE; _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } @@ -1227,7 +1163,6 @@ int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; *poid_par_priv->bytes_rw = 0; @@ -1267,7 +1202,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); -_func_exit_; return status; } @@ -1279,7 +1213,6 @@ int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_pr int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1296,7 +1229,6 @@ _func_enter_; } else { status = NDIS_STATUS_FAILURE; } -_func_exit_; return status; } @@ -1306,7 +1238,6 @@ int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); -_func_enter_; if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1321,7 +1252,6 @@ _func_enter_; ("-rtl8188eu_oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", *(int *)poid_par_priv->information_buf, status)); -_func_exit_; return status; } @@ -1330,7 +1260,6 @@ int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) { int status; -_func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_efuse_hdl\n")); @@ -1341,7 +1270,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); -_func_exit_; return status; } @@ -1353,7 +1281,6 @@ int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); u16 maplen = 0; -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_efuse_map_hdl\n")); @@ -1398,7 +1325,6 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); -_func_exit_; return status; } @@ -1414,7 +1340,6 @@ int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) u8 rx_pkt_type; int status = NDIS_STATUS_SUCCESS; -_func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_set_rx_packet_type_hdl\n")); @@ -1427,7 +1352,6 @@ _func_enter_; rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */ RT_TRACE(_module_mp_, _drv_info_, ("rx_pkt_type: %x\n", rx_pkt_type)); -_func_exit_; return status; } @@ -1482,7 +1406,6 @@ int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; -_func_enter_; if (poid_par_priv->type_of_oid != SET_OID) { status = NDIS_STATUS_NOT_ACCEPTED; @@ -1497,7 +1420,6 @@ _func_enter_; /* CALL the power_down function */ _irqlevel_changed_(&oldirql, RAISE); -_func_exit_; return status; } diff --git a/drivers/staging/rtl8188eu/core/rtw_p2p.c b/drivers/staging/rtl8188eu/core/rtw_p2p.c index 4670eb371a9d..9425c4991ccd 100644 --- a/drivers/staging/rtl8188eu/core/rtw_p2p.c +++ b/drivers/staging/rtl8188eu/core/rtw_p2p.c @@ -1498,7 +1498,6 @@ static void find_phase_handler(struct adapter *padapter) struct ndis_802_11_ssid ssid; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; _rtw_memset((unsigned char *)&ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); @@ -1509,7 +1508,6 @@ _func_enter_; spin_lock_bh(&pmlmepriv->lock); rtw_sitesurvey_cmd(padapter, &ssid, 1, NULL, 0); spin_unlock_bh(&pmlmepriv->lock); -_func_exit_; } void p2p_concurrent_handler(struct adapter *padapter); @@ -1518,7 +1516,6 @@ static void restore_p2p_state_handler(struct adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; -_func_enter_; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); @@ -1528,54 +1525,46 @@ _func_enter_; /* because this P2P client should stay at the operating channel of P2P GO. */ set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); } -_func_exit_; } static void pre_tx_invitereq_handler(struct adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 val8 = 1; -_func_enter_; set_channel_bwmode(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); issue_probereq_p2p(padapter, NULL); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); -_func_exit_; } static void pre_tx_provdisc_handler(struct adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 val8 = 1; -_func_enter_; set_channel_bwmode(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); issue_probereq_p2p(padapter, NULL); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); -_func_exit_; } static void pre_tx_negoreq_handler(struct adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 val8 = 1; -_func_enter_; set_channel_bwmode(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); issue_probereq_p2p(padapter, NULL); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); -_func_exit_; } void p2p_protocol_wk_hdl(struct adapter *padapter, int intCmdType) { -_func_enter_; switch (intCmdType) { case P2P_FIND_PHASE_WK: find_phase_handler(padapter); @@ -1594,7 +1583,6 @@ _func_enter_; break; } -_func_exit_; } void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) @@ -1610,7 +1598,6 @@ void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) u8 find_p2p = false, find_p2p_ps = false; u8 noa_offset, noa_num, noa_index; -_func_enter_; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) return; @@ -1683,7 +1670,6 @@ _func_enter_; p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); } -_func_exit_; } void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) @@ -1691,7 +1677,6 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct wifidirect_info *pwdinfo = &(padapter->wdinfo); -_func_enter_; /* Pre action for p2p state */ switch (p2p_ps_state) { @@ -1738,7 +1723,6 @@ _func_enter_; break; } -_func_exit_; } u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) @@ -1749,7 +1733,6 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) return res; @@ -1781,7 +1764,6 @@ _func_enter_; exit: -_func_exit_; return res; } diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index b5db22cc81ed..491d6af2e24d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -226,11 +226,8 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) u8 rpwm; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -_func_enter_; - pslv = PS_STATE(pslv); - if (pwrpriv->btcoex_rfon) { if (pslv < PS_STATE_S4) pslv = PS_STATE_S3; @@ -274,8 +271,6 @@ _func_enter_; pwrpriv->tog += 0x80; pwrpriv->cpwm = pslv; - -_func_exit_; } static u8 PS_RDY_CHECK(struct adapter *padapter) @@ -313,8 +308,6 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a struct wifidirect_info *pwdinfo = &(padapter->wdinfo); #endif /* CONFIG_88EU_P2P */ -_func_enter_; - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: PowerMode=%d Smart_PS=%d\n", __func__, ps_mode, smart_ps)); @@ -362,8 +355,6 @@ _func_enter_; rtw_set_rpwm(padapter, PS_STATE_S2); } } - -_func_exit_; } /* @@ -410,8 +401,6 @@ void LPS_Enter(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -_func_enter_; - if (PS_RDY_CHECK(padapter) == false) return; @@ -428,8 +417,6 @@ _func_enter_; pwrpriv->LpsIdleCount++; } } - -_func_exit_; } #define LPS_LEAVE_TIMEOUT_MS 100 @@ -440,8 +427,6 @@ void LPS_Leave(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -_func_enter_; - if (pwrpriv->bLeisurePs) { if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0); @@ -452,8 +437,6 @@ _func_enter_; } pwrpriv->bpower_saving = false; - -_func_exit_; } /* */ @@ -465,23 +448,17 @@ void LeaveAllPowerSaveMode(struct adapter *Adapter) struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); u8 enqueue = 0; -_func_enter_; - if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, enqueue); rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue); } - -_func_exit_; } void rtw_init_pwrctrl_priv(struct adapter *padapter) { struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; -_func_enter_; - _init_pwrlock(&pwrctrlpriv->lock); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; @@ -518,8 +495,6 @@ _func_enter_; pwrctrlpriv->btcoex_rfon = false; _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter); - -_func_exit_; } u8 rtw_interface_ps_func(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index e624afe0f86b..c8491f69ccd3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -44,7 +44,6 @@ void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { -_func_enter_; _rtw_memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); @@ -52,7 +51,6 @@ _func_enter_; _rtw_init_queue(&psta_recvpriv->defrag_q); -_func_exit_; } int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) @@ -63,7 +61,6 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) int res = _SUCCESS; -_func_enter_; spin_lock_init(&precvpriv->lock); _rtw_init_queue(&precvpriv->free_recv_queue); @@ -112,7 +109,6 @@ _func_enter_; rtw_set_signal_stat_timer(precvpriv); exit: -_func_exit_; return res; } @@ -121,7 +117,6 @@ void _rtw_free_recv_priv (struct recv_priv *precvpriv) { struct adapter *padapter = precvpriv->adapter; -_func_enter_; rtw_free_uc_swdec_pending_queue(padapter); @@ -133,7 +128,6 @@ _func_enter_; rtw_hal_free_recv_priv(padapter); -_func_exit_; } union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) @@ -142,7 +136,6 @@ union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) struct list_head *plist, *phead; struct adapter *padapter; struct recv_priv *precvpriv; -_func_enter_; if (_rtw_queue_empty(pfree_recv_queue)) { hdr = NULL; @@ -162,7 +155,6 @@ _func_enter_; } } -_func_exit_; return (union recv_frame *)hdr; } @@ -193,7 +185,6 @@ int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_ struct adapter *padapter; struct recv_priv *precvpriv; -_func_enter_; if (!precvframe) return _FAIL; padapter = precvframe->u.hdr.adapter; @@ -218,7 +209,6 @@ _func_enter_; spin_unlock_bh(&pfree_recv_queue->lock); -_func_exit_; return _SUCCESS; } @@ -228,7 +218,6 @@ int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) struct adapter *padapter = precvframe->u.hdr.adapter; struct recv_priv *precvpriv = &padapter->recvpriv; -_func_enter_; rtw_list_delete(&(precvframe->u.hdr.list)); rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(queue)); @@ -238,7 +227,6 @@ _func_enter_; precvpriv->free_recvframe_cnt++; } -_func_exit_; return _SUCCESS; } @@ -267,7 +255,6 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre struct recv_frame_hdr *hdr; struct list_head *plist, *phead; -_func_enter_; spin_lock(&pframequeue->lock); phead = get_list_head(pframequeue); @@ -283,7 +270,6 @@ _func_enter_; spin_unlock(&pframequeue->lock); -_func_exit_; } u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) @@ -362,7 +348,6 @@ static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvfra struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -_func_enter_; stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); @@ -470,7 +455,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -482,7 +466,6 @@ static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *p struct security_priv *psecuritypriv = &padapter->securitypriv; union recv_frame *return_packet = precv_frame; u32 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted=%x prxattrib->encrypt=0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); @@ -533,7 +516,6 @@ _func_enter_; return_packet = NULL; } -_func_exit_; return return_packet; } @@ -552,7 +534,6 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre struct rx_pkt_attrib *pattrib; __be16 be_tmp; -_func_enter_; pstapriv = &adapter->stapriv; psta = rtw_get_stainfo(pstapriv, psta_addr); @@ -612,7 +593,6 @@ _func_enter_; prtnframe = precv_frame; } -_func_exit_; return prtnframe; } @@ -624,7 +604,6 @@ static int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | (precv_frame->u.hdr.attrib.frag_num & 0xf); -_func_enter_; if (tid > 15) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, (tid>15)! seq_ctrl=0x%x, tid=0x%x\n", seq_ctrl, tid)); @@ -642,7 +621,6 @@ _func_enter_; prxcache->tid_rxseq[tid] = seq_ctrl; -_func_exit_; return _SUCCESS; } @@ -776,7 +754,6 @@ int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, s u8 *sta_addr = NULL; int bmcast = IS_MCAST(pattrib->dst); -_func_enter_; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { @@ -852,7 +829,6 @@ _func_enter_; } exit: -_func_exit_; return ret; } @@ -870,7 +846,6 @@ static int ap2sta_data_frame ( u8 *myhwaddr = myid(&adapter->eeprompriv); int bmcast = IS_MCAST(pattrib->dst); -_func_enter_; if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && (check_fwstate(pmlmepriv, _FW_LINKED) == true || @@ -963,7 +938,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -979,7 +953,6 @@ static int sta2ap_data_frame(struct adapter *adapter, unsigned char *mybssid = get_bssid(pmlmepriv); int ret = _SUCCESS; -_func_enter_; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ @@ -1025,7 +998,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -1206,7 +1178,6 @@ static int validate_recv_data_frame(struct adapter *adapter, struct security_priv *psecuritypriv = &adapter->securitypriv; int ret = _SUCCESS; -_func_enter_; bretry = GetRetry(ptr); pda = get_da(ptr); @@ -1311,7 +1282,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -1331,7 +1301,6 @@ static int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_ u8 ver = (unsigned char) (*ptr)&0x3; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; -_func_enter_; if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { int ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, rtw_get_oper_ch(adapter)); @@ -1421,7 +1390,6 @@ _func_enter_; exit: -_func_exit_; return retval; } @@ -1444,7 +1412,6 @@ static int wlanhdr_to_ethhdr (union recv_frame *precvframe) u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; -_func_enter_; if (pattrib->encrypt) recvframe_pull_tail(precvframe, pattrib->icv_len); @@ -1495,7 +1462,6 @@ _func_enter_; memcpy(ptr+12, &be_tmp, 2); } -_func_exit_; return ret; } @@ -1509,7 +1475,6 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queu union recv_frame *prframe, *pnextrframe; struct __queue *pfree_recv_queue; -_func_enter_; curfragnum = 0; pfree_recv_queue = &adapter->recvpriv.free_recv_queue; @@ -1575,7 +1540,6 @@ _func_enter_; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n")); -_func_exit_; return prframe; } @@ -1593,7 +1557,6 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram union recv_frame *prtnframe = NULL; struct __queue *pfree_recv_queue, *pdefrag_q; -_func_enter_; pstapriv = &padapter->stapriv; @@ -1678,7 +1641,6 @@ _func_enter_; } } -_func_exit_; return prtnframe; } @@ -2200,7 +2162,6 @@ s32 rtw_recv_entry(union recv_frame *precvframe) struct recv_priv *precvpriv; s32 ret = _SUCCESS; -_func_enter_; padapter = precvframe->u.hdr.adapter; @@ -2214,7 +2175,6 @@ _func_enter_; precvpriv->rx_pkts++; -_func_exit_; return ret; @@ -2223,7 +2183,6 @@ _recv_entry_drop: if (padapter->registrypriv.mp_mode == 1) padapter->mppriv.rx_pktloss = precvpriv->rx_drop; -_func_exit_; return ret; } diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index e08845729772..c3ce56989ea6 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -41,7 +41,6 @@ static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) u32 stateindex; u8 *state; u32 counter; -_func_enter_; state = parc4ctx->state; parc4ctx->x = 0; parc4ctx->y = 0; @@ -58,7 +57,6 @@ _func_enter_; if (++keyindex >= key_len) keyindex = 0; } -_func_exit_; } static u32 arcfour_byte(struct arc4context *parc4ctx) @@ -67,7 +65,6 @@ static u32 arcfour_byte(struct arc4context *parc4ctx) u32 y; u32 sx, sy; u8 *state; -_func_enter_; state = parc4ctx->state; x = (parc4ctx->x + 1) & 0xff; sx = state[x]; @@ -77,17 +74,14 @@ _func_enter_; parc4ctx->y = y; state[y] = (u8)sx; state[x] = (u8)sy; -_func_exit_; return state[(sx + sy) & 0xff]; } static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) { u32 i; -_func_enter_; for (i = 0; i < len; i++) dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); -_func_exit_; } static int bcrc32initialized; @@ -102,9 +96,8 @@ static u8 crc32_reverseBit(u8 data) static void crc32_init(void) { -_func_enter_; if (bcrc32initialized == 1) { - goto exit; + return; } else { int i, j; u32 c; @@ -126,15 +119,12 @@ _func_enter_; } bcrc32initialized = 1; } -exit: -_func_exit_; } static __le32 getcrc32(u8 *buf, int len) { u8 *p; u32 crc; -_func_enter_; if (bcrc32initialized == 0) crc32_init(); @@ -142,7 +132,6 @@ _func_enter_; for (p = buf; len > 0; ++p, --len) crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); -_func_exit_; return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ } @@ -165,7 +154,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -_func_enter_; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return; @@ -206,7 +194,6 @@ _func_enter_; } } -_func_exit_; } void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) @@ -221,7 +208,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) struct rx_pkt_attrib *prxattrib = &(((union recv_frame *)precvframe)->u.hdr.attrib); struct security_priv *psecuritypriv = &padapter->securitypriv; -_func_enter_; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; @@ -252,7 +238,6 @@ _func_enter_; &crc, &payload[length-4])); } } -_func_exit_; return; } @@ -263,10 +248,8 @@ static u32 secmicgetuint32(u8 *p) { s32 i; u32 res = 0; -_func_enter_; for (i = 0; i < 4; i++) res |= ((u32)(*p++)) << (8*i); -_func_exit_; return res; } @@ -274,39 +257,32 @@ static void secmicputuint32(u8 *p, u32 val) /* Convert from Us3232 to Byte[] in a portable way */ { long i; -_func_enter_; for (i = 0; i < 4; i++) { *p++ = (u8) (val & 0xff); val >>= 8; } -_func_exit_; } static void secmicclear(struct mic_data *pmicdata) { /* Reset the state to the empty message. */ -_func_enter_; pmicdata->L = pmicdata->K0; pmicdata->R = pmicdata->K1; pmicdata->nBytesInM = 0; pmicdata->M = 0; -_func_exit_; } void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) { /* Set the key */ -_func_enter_; pmicdata->K0 = secmicgetuint32(key); pmicdata->K1 = secmicgetuint32(key + 4); /* and reset the message */ secmicclear(pmicdata); -_func_exit_; } void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) { -_func_enter_; /* Append the byte to our word-sized buffer */ pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); pmicdata->nBytesInM++; @@ -325,23 +301,19 @@ _func_enter_; pmicdata->M = 0; pmicdata->nBytesInM = 0; } -_func_exit_; } void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes) { -_func_enter_; /* This is simple */ while (nbytes > 0) { rtw_secmicappendbyte(pmicdata, *src++); nbytes--; } -_func_exit_; } void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) { -_func_enter_; /* Append the minimum padding */ rtw_secmicappendbyte(pmicdata, 0x5a); rtw_secmicappendbyte(pmicdata, 0); @@ -356,14 +328,12 @@ _func_enter_; secmicputuint32(dst+4, pmicdata->R); /* Reset to the empty message. */ secmicclear(pmicdata); -_func_exit_; } void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) { struct mic_data micdata; u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; -_func_enter_; rtw_secmicsetkey(&micdata, key); priority[0] = pri; @@ -386,7 +356,6 @@ _func_enter_; rtw_secmicappend(&micdata, data, data_len); rtw_secgetmic(&micdata, mic_code); -_func_exit_; } @@ -505,7 +474,6 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) { int i; -_func_enter_; /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ p1k[0] = Lo16(iv32); p1k[1] = Hi16(iv32); @@ -523,7 +491,6 @@ _func_enter_; p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ } -_func_exit_; } /* @@ -553,7 +520,6 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) { int i; u16 PPK[6]; /* temporary key for mixing */ -_func_enter_; /* Note: all adds in the PPK[] equations below are mod 2**16 */ for (i = 0; i < 5; i++) PPK[i] = p1k[i]; /* first, copy P1K to PPK */ @@ -590,7 +556,6 @@ _func_enter_; rc4key[4+2*i] = Lo8(PPK[i]); rc4key[5+2*i] = Hi8(PPK[i]); } -_func_exit_; } /* The hlen isn't include the IV */ @@ -612,7 +577,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; -_func_enter_; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -672,7 +636,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; return res; } @@ -694,7 +657,6 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; -_func_enter_; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; @@ -747,7 +709,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; exit: return res; } @@ -821,19 +782,15 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext); static void xor_128(u8 *a, u8 *b, u8 *out) { int i; -_func_enter_; for (i = 0; i < 16; i++) out[i] = a[i] ^ b[i]; -_func_exit_; } static void xor_32(u8 *a, u8 *b, u8 *out) { int i; -_func_enter_; for (i = 0; i < 4; i++) out[i] = a[i] ^ b[i]; -_func_exit_; } static u8 sbox(u8 a) @@ -849,7 +806,6 @@ static void next_key(u8 *key, int round) 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x36, 0x36 }; -_func_enter_; sbox_key[0] = sbox(key[13]); sbox_key[1] = sbox(key[14]); sbox_key[2] = sbox(key[15]); @@ -863,21 +819,17 @@ _func_enter_; xor_32(&key[4], &key[0], &key[4]); xor_32(&key[8], &key[4], &key[8]); xor_32(&key[12], &key[8], &key[12]); -_func_exit_; } static void byte_sub(u8 *in, u8 *out) { int i; -_func_enter_; for (i = 0; i < 16; i++) out[i] = sbox(in[i]); -_func_exit_; } static void shift_row(u8 *in, u8 *out) { -_func_enter_; out[0] = in[0]; out[1] = in[5]; out[2] = in[10]; @@ -894,7 +846,6 @@ _func_enter_; out[13] = in[1]; out[14] = in[6]; out[15] = in[11]; -_func_exit_; } static void mix_column(u8 *in, u8 *out) @@ -908,7 +859,6 @@ static void mix_column(u8 *in, u8 *out) u8 rotr[4]; u8 temp[4]; u8 tempb[4]; -_func_enter_; for (i = 0 ; i < 4; i++) { if ((in[i] & 0x80) == 0x80) add1b[i] = 0x1b; @@ -952,7 +902,6 @@ _func_enter_; xor_32(add1bf7, rotr, temp); xor_32(swap_halfs, rotl, tempb); xor_32(temp, tempb, out); -_func_exit_; } static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) @@ -962,7 +911,6 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) u8 intermediatea[16]; u8 intermediateb[16]; u8 round_key[16]; -_func_enter_; for (i = 0; i < 16; i++) round_key[i] = key[i]; for (round = 0; round < 11; round++) { @@ -984,7 +932,6 @@ _func_enter_; next_key(round_key, round); } } -_func_exit_; } /************************************************/ @@ -995,7 +942,6 @@ static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector) { int i; -_func_enter_; mic_iv[0] = 0x59; if (qc_exists && a4_exists) mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ @@ -1009,7 +955,6 @@ _func_enter_; mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ mic_iv[14] = (unsigned char) (payload_length / 256); mic_iv[15] = (unsigned char) (payload_length % 256); -_func_exit_; } /************************************************/ @@ -1019,7 +964,6 @@ _func_exit_; /************************************************/ static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu) { -_func_enter_; mic_header1[0] = (u8)((header_length - 2) / 256); mic_header1[1] = (u8)((header_length - 2) % 256); mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ @@ -1036,7 +980,6 @@ _func_enter_; mic_header1[13] = mpdu[13]; mic_header1[14] = mpdu[14]; mic_header1[15] = mpdu[15]; -_func_exit_; } /************************************************/ @@ -1047,7 +990,6 @@ _func_exit_; static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists) { int i; -_func_enter_; for (i = 0; i < 16; i++) mic_header2[i] = 0x00; @@ -1079,7 +1021,6 @@ _func_enter_; mic_header2[15] = mpdu[31] & 0x00; } -_func_exit_; } /************************************************/ @@ -1090,7 +1031,6 @@ _func_exit_; static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c) { int i; -_func_enter_; for (i = 0; i < 16; i++) ctr_preload[i] = 0x00; i = 0; @@ -1107,7 +1047,6 @@ _func_enter_; ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ ctr_preload[15] = (unsigned char) (c % 256); -_func_exit_; } /************************************/ @@ -1117,10 +1056,8 @@ _func_exit_; static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) { int i; -_func_enter_; for (i = 0; i < 16; i++) out[i] = ina[i] ^ inb[i]; -_func_exit_; } static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) @@ -1142,7 +1079,6 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); -_func_enter_; frsubtype = frsubtype>>4; _rtw_memset((void *)mic_iv, 0, 16); @@ -1253,7 +1189,6 @@ _func_enter_; bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < 8; j++) pframe[payload_index++] = chain_buffer[j]; -_func_exit_; return _SUCCESS; } @@ -1274,7 +1209,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* uint offset = 0; */ u32 res = _SUCCESS; -_func_enter_; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -1318,7 +1252,6 @@ _func_enter_; } -_func_exit_; return res; } @@ -1344,7 +1277,6 @@ static int aes_decipher(u8 *key, uint hdrlen, /* uint offset = 0; */ uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); -_func_enter_; frsubtype = frsubtype>>4; _rtw_memset((void *)mic_iv, 0, 16); @@ -1514,7 +1446,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; return res; } @@ -1527,7 +1458,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; -_func_enter_; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; /* 4 start to encrypt each fragment */ if ((prxattrib->encrypt == _AES_)) { @@ -1559,7 +1489,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; exit: return res; } @@ -1767,7 +1696,6 @@ void rtw_use_tkipkey_handler(void *FunctionContext) { struct adapter *padapter = (struct adapter *)FunctionContext; -_func_enter_; RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler ^^^\n")); @@ -1775,5 +1703,4 @@ _func_enter_; RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler padapter->securitypriv.busetkipkey=%d^^^\n", padapter->securitypriv.busetkipkey)); -_func_exit_; } diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 5c9326d12f5f..a59f062aa2e4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -29,7 +29,6 @@ static void _rtw_init_stainfo(struct sta_info *psta) { -_func_enter_; _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); spin_lock_init(&psta->lock); @@ -70,7 +69,6 @@ _func_enter_; #endif /* CONFIG_88EU_AP_MODE */ -_func_exit_; } u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) @@ -78,7 +76,6 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) struct sta_info *psta; s32 i; -_func_enter_; pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4); @@ -126,7 +123,6 @@ _func_enter_; pstapriv->max_num_sta = NUM_STA; #endif -_func_exit_; return _SUCCESS; } @@ -155,7 +151,6 @@ static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) struct list_head *plist, *phead; struct sta_info *psta = NULL; -_func_enter_; spin_lock_bh(&pstapriv->sta_hash_lock); @@ -169,7 +164,6 @@ _func_enter_; spin_unlock_bh(&pstapriv->sta_hash_lock); -_func_exit_; } static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) @@ -184,7 +178,6 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) struct recv_reorder_ctrl *preorder_ctrl; int index; -_func_enter_; if (pstapriv) { /* delete all reordering_ctrl_timer */ spin_lock_bh(&pstapriv->sta_hash_lock); @@ -212,7 +205,6 @@ _func_enter_; vfree(pstapriv->pallocated_stainfo_buf); } -_func_exit_; return _SUCCESS; } @@ -226,7 +218,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) int i = 0; u16 wRxSeqInitialValue = 0xffff; -_func_enter_; pfree_sta_queue = &pstapriv->free_sta_queue; @@ -298,9 +289,6 @@ _func_enter_; } exit: - -_func_exit_; - return psta; } @@ -314,7 +302,6 @@ u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct sta_priv *pstapriv = &padapter->stapriv; -_func_enter_; if (psta == NULL) goto exit; @@ -431,7 +418,6 @@ _func_enter_; exit: -_func_exit_; return _SUCCESS; } @@ -445,10 +431,9 @@ void rtw_free_all_stainfo(struct adapter *padapter) struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); -_func_enter_; if (pstapriv->asoc_sta_count == 1) - goto exit; + return; spin_lock_bh(&pstapriv->sta_hash_lock); @@ -465,12 +450,7 @@ _func_enter_; rtw_free_stainfo(padapter , psta); } } - spin_unlock_bh(&pstapriv->sta_hash_lock); - -exit: - -_func_exit_; } /* any station allocated can be searched by hash list */ @@ -482,7 +462,6 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -_func_enter_; if (hwaddr == NULL) return NULL; @@ -511,7 +490,6 @@ _func_enter_; } spin_unlock_bh(&pstapriv->sta_hash_lock); -_func_exit_; return psta; } @@ -522,7 +500,6 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sta_priv *pstapriv = &padapter->stapriv; -_func_enter_; psta = rtw_alloc_stainfo(pstapriv, bcast_addr); @@ -536,7 +513,6 @@ _func_enter_; psta->mac_id = 1; exit: -_func_exit_; return res; } @@ -545,9 +521,7 @@ struct sta_info *rtw_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}; -_func_enter_; psta = rtw_get_stainfo(pstapriv, bc_addr); -_func_exit_; return psta; } diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 2c8d58db65fe..f64b9795a712 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1090,12 +1090,10 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } kfree(bssid); - _func_exit_; return _SUCCESS; _mismatch: kfree(bssid); - _func_exit_; return _FAIL; } diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 3b584b450941..48d57be0856c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -32,16 +32,13 @@ static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; static void _init_txservq(struct tx_servq *ptxservq) { -_func_enter_; _rtw_init_listhead(&ptxservq->tx_pending); _rtw_init_queue(&ptxservq->sta_pending); ptxservq->qcnt = 0; -_func_exit_; } void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) { -_func_enter_; _rtw_memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); spin_lock_init(&psta_xmitpriv->lock); _init_txservq(&psta_xmitpriv->be_q); @@ -51,7 +48,6 @@ _func_enter_; _rtw_init_listhead(&psta_xmitpriv->legacy_dz); _rtw_init_listhead(&psta_xmitpriv->apsd); -_func_exit_; } s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) @@ -63,7 +59,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; -_func_enter_; /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ @@ -226,7 +221,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -240,12 +234,11 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - _func_enter_; rtw_hal_free_xmit_priv(padapter); if (pxmitpriv->pxmit_frame_buf == NULL) - goto out; + return; for (i = 0; i < NR_XMITFRAME; i++) { rtw_os_xmit_complete(padapter, pxmitframe); @@ -278,10 +271,6 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) rtw_free_hwxmits(padapter); mutex_destroy(&pxmitpriv->ack_tx_mutex); - -out: - -_func_exit_; } static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe) @@ -455,7 +444,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p struct qos_priv *pqospriv = &pmlmepriv->qospriv; int res = _SUCCESS; - _func_enter_; _rtw_open_pktfile(pkt, &pktfile); _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); @@ -639,7 +627,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p exit: -_func_exit_; return res; } @@ -662,7 +649,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr else stainfo = rtw_get_stainfo(&padapter->stapriv , &pattrib->ra[0]); -_func_enter_; hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); @@ -760,7 +746,6 @@ _func_enter_; } } -_func_exit_; return _SUCCESS; } @@ -769,7 +754,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi { struct pkt_attrib *pattrib = &pxmitframe->attrib; -_func_enter_; if (pattrib->bswenc) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); @@ -791,7 +775,6 @@ _func_enter_; RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); } -_func_exit_; return _SUCCESS; } @@ -812,7 +795,6 @@ s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pat int bmcst = IS_MCAST(pattrib->ra); -_func_enter_; if (pattrib->psta) { psta = pattrib->psta; @@ -918,7 +900,6 @@ _func_enter_; } exit: -_func_exit_; return res; } @@ -1007,7 +988,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct s32 bmcst = IS_MCAST(pattrib->ra); s32 res = _SUCCESS; -_func_enter_; psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); @@ -1145,7 +1125,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1162,7 +1141,6 @@ s32 rtw_put_snap(u8 *data, u16 h_proto) struct ieee80211_snap_hdr *snap; u8 *oui; -_func_enter_; snap = (struct ieee80211_snap_hdr *)data; snap->dsap = 0xaa; @@ -1180,7 +1158,6 @@ _func_enter_; *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); -_func_exit_; return SNAP_SIZE + sizeof(u16); } @@ -1193,7 +1170,6 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; -_func_enter_; switch (pxmitpriv->vcs_setting) { case DISABLE_VCS: @@ -1220,7 +1196,6 @@ _func_enter_; break; } -_func_exit_; } void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) @@ -1250,7 +1225,6 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) struct list_head *plist, *phead; struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; -_func_enter_; spin_lock_irqsave(&pfree_queue->lock, irql); @@ -1280,7 +1254,6 @@ _func_enter_; spin_unlock_irqrestore(&pfree_queue->lock, irql); -_func_exit_; return pxmitbuf; } @@ -1290,7 +1263,6 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) unsigned long irql; struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; -_func_enter_; if (pxmitbuf == NULL) return _FAIL; @@ -1304,7 +1276,6 @@ _func_enter_; spin_unlock_irqrestore(&pfree_queue->lock, irql); -_func_exit_; return _SUCCESS; } @@ -1316,7 +1287,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) struct list_head *plist, *phead; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; -_func_enter_; /* DBG_88E("+rtw_alloc_xmitbuf\n"); */ @@ -1344,7 +1314,6 @@ _func_enter_; } spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); -_func_exit_; return pxmitbuf; } @@ -1354,7 +1323,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) unsigned long irql; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; -_func_enter_; if (pxmitbuf == NULL) return _FAIL; @@ -1376,7 +1344,6 @@ _func_enter_; spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); } -_func_exit_; return _SUCCESS; } @@ -1405,7 +1372,6 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf struct list_head *plist, *phead; struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; -_func_enter_; spin_lock_bh(&pfree_xmit_queue->lock); @@ -1444,7 +1410,6 @@ _func_enter_; spin_unlock_bh(&pfree_xmit_queue->lock); -_func_exit_; return pxframe; } @@ -1455,7 +1420,6 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram struct adapter *padapter = pxmitpriv->adapter; struct sk_buff *pndis_pkt = NULL; -_func_enter_; if (pxmitframe == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); @@ -1483,7 +1447,6 @@ _func_enter_; exit: -_func_exit_; return _SUCCESS; } @@ -1493,7 +1456,6 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram struct list_head *plist, *phead; struct xmit_frame *pxmitframe; -_func_enter_; spin_lock_bh(&(pframequeue->lock)); @@ -1509,7 +1471,6 @@ _func_enter_; } spin_unlock_bh(&(pframequeue->lock)); -_func_exit_; } s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) @@ -1555,7 +1516,6 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi struct registry_priv *pregpriv = &padapter->registrypriv; int i, inx[4]; -_func_enter_; inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; @@ -1595,7 +1555,6 @@ _func_enter_; } exit: spin_unlock_bh(&pxmitpriv->lock); -_func_exit_; return pxmitframe; } @@ -1603,7 +1562,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * { struct tx_servq *ptxservq; -_func_enter_; switch (up) { case 1: case 2: @@ -1632,7 +1590,6 @@ _func_enter_; break; } -_func_exit_; return ptxservq; } @@ -1651,7 +1608,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; int res = _SUCCESS; -_func_enter_; if (pattrib->psta) { psta = pattrib->psta; @@ -1676,7 +1632,6 @@ _func_enter_; phwxmits[ac_index].accnt++; exit: -_func_exit_; return res; } @@ -1719,10 +1674,8 @@ void rtw_free_hwxmits(struct adapter *padapter) void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry) { int i; -_func_enter_; for (i = 0; i < entry; i++, phwxmit++) phwxmit->accnt = 0; -_func_exit_; } static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index 598140464f05..d75ca7a27c86 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -116,8 +116,6 @@ uint rtw_hal_deinit(struct adapter *adapt) { uint status = _SUCCESS; -_func_enter_; - status = adapt->HalFunc.hal_deinit(adapt); if (status == _SUCCESS) @@ -125,8 +123,6 @@ _func_enter_; else DBG_88E("\n rtw_hal_deinit: hal_init fail\n"); -_func_exit_; - return status; } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index ca0a7085445f..021e5879abcf 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -72,7 +72,6 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p u32 h2c_cmd_ex = 0; s32 ret = _FAIL; -_func_enter_; if (!adapt->bFWReady) { DBG_88E("FillH2CCmd_88E(): return H2C cmd because fw is not ready\n"); @@ -125,7 +124,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -134,7 +132,6 @@ u8 rtl8188e_set_rssi_cmd(struct adapter *adapt, u8 *param) { u8 res = _SUCCESS; struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); -_func_enter_; if (haldata->fw_ractrl) { ; @@ -143,7 +140,6 @@ _func_enter_; res = _FAIL; } -_func_exit_; return res; } @@ -154,7 +150,6 @@ u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask) u8 res = _SUCCESS; struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); -_func_enter_; if (haldata->fw_ractrl) { __le32 lmask; @@ -168,7 +163,6 @@ _func_enter_; res = _FAIL; } -_func_exit_; return res; } @@ -215,7 +209,6 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) struct setpwrmode_parm H2CSetPwrMode; struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv; u8 RLBM = 0; /* 0:Min, 1:Max, 2:User define */ -_func_enter_; DBG_88E("%s: Mode=%d SmartPS=%d UAPSD=%d\n", __func__, Mode, pwrpriv->smart_ps, adapt->registrypriv.uapsd_enable); @@ -256,7 +249,6 @@ _func_enter_; FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); -_func_exit_; } void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) @@ -617,7 +609,6 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) u8 DLBcnCount = 0; u32 poll = 0; -_func_enter_; DBG_88E("%s mstatus(%x)\n", __func__, mstatus); @@ -701,7 +692,6 @@ _func_enter_; haldata->RegCR_1 &= (~BIT0); rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); } -_func_exit_; } void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state) @@ -712,7 +702,6 @@ void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state) struct P2P_PS_Offload_t *p2p_ps_offload = &haldata->p2p_ps_offload; u8 i; -_func_enter_; switch (p2p_ps_state) { case P2P_PS_DISABLE: @@ -775,5 +764,4 @@ _func_enter_; FillH2CCmd_88E(adapt, H2C_PS_P2P_OFFLOAD, 1, (u8 *)p2p_ps_offload); #endif -_func_exit_; } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index 4c934e2e0911..cf88bf247c85 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -160,7 +160,6 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) u8 hw_init_completed = false; struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); - _func_enter_; hw_init_completed = Adapter->hw_init_completed; if (!hw_init_completed) @@ -178,7 +177,6 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) /* Calculate Tx/Rx statistics. */ dm_CheckStatistics(Adapter); - _func_exit_; } /* ODM */ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 524899510355..13c06196073c 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -708,10 +708,8 @@ void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) static void rtl8188e_free_hal_data(struct adapter *padapter) { -_func_enter_; kfree(padapter->HalData); padapter->HalData = NULL; -_func_exit_; } /* */ diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index b24ad495062c..c92067f0ef15 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -709,7 +709,6 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) #define HAL_INIT_PROFILE_TAG(stage) do {} while (0) -_func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BEGIN); @@ -967,7 +966,6 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); DBG_88E("%s in %dms\n", __func__, rtw_get_passing_time_ms(init_start_time)); -_func_exit_; return status; } @@ -1084,7 +1082,6 @@ static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) struct recv_priv *precvpriv = &(Adapter->recvpriv); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); -_func_enter_; _read_port = pintfhdl->io_ops._read_port; @@ -1112,7 +1109,6 @@ exit: RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); -_func_exit_; return status; } @@ -1402,7 +1398,6 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &haldata->dmpriv; struct odm_dm_struct *podmpriv = &haldata->odmpriv; -_func_enter_; switch (variable) { case HW_VAR_MEDIA_STATUS: @@ -1921,14 +1916,12 @@ _func_enter_; default: break; } -_func_exit_; } static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct odm_dm_struct *podmpriv = &haldata->odmpriv; -_func_enter_; switch (variable) { case HW_VAR_BASIC_RATE: @@ -1980,7 +1973,6 @@ _func_enter_; break; } -_func_exit_; } /* */ @@ -2302,7 +2294,6 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt) { struct hal_ops *halfunc = &adapt->HalFunc; -_func_enter_; adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); if (adapt->HalData == NULL) @@ -2342,5 +2333,4 @@ _func_enter_; halfunc->interface_ps_func = &rtl8188eu_ps_func; rtl8188e_set_hal_ops(halfunc); -_func_exit_; } diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index 31ae21a54c92..74ee2e6ae902 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -125,7 +125,6 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u16 len; u8 data = 0; - _func_enter_; request = 0x05; requesttype = 0x01;/* read_in */ @@ -136,7 +135,6 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - _func_exit_; return data; @@ -151,14 +149,12 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u16 len; __le32 data; -_func_enter_; request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ wvalue = (u16)(addr&0x0000ffff); len = 2; usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); -_func_exit_; return (u16)(le32_to_cpu(data)&0xffff); } @@ -172,7 +168,6 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) u16 len; __le32 data; -_func_enter_; request = 0x05; requesttype = 0x01;/* read_in */ @@ -183,7 +178,6 @@ _func_enter_; usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); -_func_exit_; return le32_to_cpu(data); } @@ -198,7 +192,6 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) u8 data; int ret; - _func_enter_; request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -206,7 +199,6 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) len = 1; data = val; ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - _func_exit_; return ret; } @@ -220,7 +212,6 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) __le32 data; int ret; - _func_enter_; request = 0x05; requesttype = 0x00;/* write_out */ @@ -233,7 +224,6 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - _func_exit_; return ret; } @@ -248,7 +238,6 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) __le32 data; int ret; - _func_enter_; request = 0x05; requesttype = 0x00;/* write_out */ @@ -260,7 +249,6 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - _func_exit_; return ret; } @@ -275,7 +263,6 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; int ret; - _func_enter_; request = 0x05; requesttype = 0x00;/* write_out */ @@ -287,7 +274,6 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); - _func_exit_; return ret; } @@ -519,7 +505,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", __func__, adapt->bDriverStopped, adapt->bSurpriseRemoved, adapt->bReadPortCancel); - goto exit; + return; } if (purb->status == 0) { /* SUCCESS */ @@ -579,9 +565,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) break; } } - -exit: -_func_exit_; } static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) @@ -598,7 +581,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) size_t alignment = 0; u32 ret = _SUCCESS; -_func_enter_; if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) { @@ -672,7 +654,6 @@ _func_enter_; ret = _FAIL; } -_func_exit_; return ret; } @@ -702,7 +683,6 @@ void rtl8188eu_xmit_tasklet(void *priv) void rtl8188eu_set_intf_ops(struct _io_ops *pops) { - _func_enter_; _rtw_memset((u8 *)pops, 0, sizeof(struct _io_ops)); pops->_read8 = &usb_read8; pops->_read16 = &usb_read16; @@ -717,7 +697,6 @@ void rtl8188eu_set_intf_ops(struct _io_ops *pops) pops->_write_port = &usb_write_port; pops->_read_port_cancel = &usb_read_port_cancel; pops->_write_port_cancel = &usb_write_port_cancel; - _func_exit_; } void rtl8188eu_set_hw_type(struct adapter *adapt) diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h index c6b193a2e795..1cdc07dcb87c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_debug.h +++ b/drivers/staging/rtl8188eu/include/rtw_debug.h @@ -99,20 +99,6 @@ extern u32 GlobalDebugLevel; } \ } while (0) -#define _func_enter_ \ - do { \ - if (GlobalDebugLevel >= _drv_debug_) \ - pr_info("%s : %s enters at %d\n", \ - DRIVER_PREFIX, __func__, __LINE__); \ - } while (0) - -#define _func_exit_ \ - do { \ - if (GlobalDebugLevel >= _drv_debug_) \ - pr_info("%s : %s exits at %d\n", \ - DRIVER_PREFIX, __func__, __LINE__); \ - } while (0) - #define RT_PRINT_DATA(_comp, _level, _titlestring, _hexdata, _hexdatalen)\ do { \ if (_level <= GlobalDebugLevel) { \ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h index 8772d1d178c6..f3aa924f2029 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h @@ -102,8 +102,6 @@ struct oid_obj_priv { #if defined(_RTW_MP_IOCTL_C_) static int oid_null_function(struct oid_par_priv *poid_par_priv) { - _func_enter_; - _func_exit_; return NDIS_STATUS_SUCCESS; } #endif diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 08be34ef5e14..7de813986ff0 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -473,8 +473,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ -_func_enter_; - param->u.crypt.err = 0; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; @@ -615,9 +613,6 @@ _func_enter_; exit: kfree(pwep); - -_func_exit_; - return ret; } @@ -771,8 +766,6 @@ static int rtw_wx_get_name(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); - _func_enter_; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); @@ -807,9 +800,6 @@ static int rtw_wx_get_name(struct net_device *dev, } else { snprintf(wrqu->name, IFNAMSIZ, "unassociated"); } - - _func_exit_; - return 0; } @@ -817,12 +807,7 @@ static int rtw_wx_set_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - _func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n")); - - _func_exit_; - return 0; } @@ -855,8 +840,6 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, enum ndis_802_11_network_infra networkType; int ret = 0; - _func_enter_; - if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -EPERM; goto exit; @@ -895,7 +878,6 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, } rtw_setopmode_cmd(padapter, networkType); exit: - _func_exit_; return ret; } @@ -907,8 +889,6 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); - _func_enter_; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) wrqu->mode = IW_MODE_INFRA; else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || @@ -919,8 +899,6 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, else wrqu->mode = IW_MODE_AUTO; - _func_exit_; - return 0; } @@ -1012,8 +990,6 @@ static int rtw_wx_get_range(struct net_device *dev, u16 val; int i; - _func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); wrqu->data.length = sizeof(*range); @@ -1094,8 +1070,6 @@ static int rtw_wx_get_range(struct net_device *dev, range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; - _func_exit_; - return 0; } @@ -1119,8 +1093,6 @@ static int rtw_wx_set_wap(struct net_device *dev, struct wlan_network *pnetwork = NULL; enum ndis_802_11_auth_mode authmode; - _func_enter_; - if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -1; goto exit; @@ -1174,8 +1146,6 @@ static int rtw_wx_set_wap(struct net_device *dev, exit: - _func_exit_; - return ret; } @@ -1193,17 +1163,12 @@ static int rtw_wx_get_wap(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); - _func_enter_; - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); else _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - - _func_exit_; - return 0; } @@ -1253,7 +1218,6 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, #endif /* CONFIG_88EU_P2P */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); -_func_enter_; if (padapter->registrypriv.mp_mode == 1) { if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { ret = -1; @@ -1384,7 +1348,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -1408,8 +1371,6 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); - _func_enter_; - if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { ret = -EINVAL; goto exit; @@ -1467,7 +1428,6 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, wrqu->data.flags = 0; exit: - _func_exit_; return ret; } @@ -1491,7 +1451,6 @@ static int rtw_wx_set_essid(struct net_device *dev, uint ret = 0, len; - _func_enter_; RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); @@ -1584,7 +1543,6 @@ exit: DBG_88E("<=%s, ret %d\n", __func__, ret); - _func_exit_; return ret; } @@ -1600,7 +1558,6 @@ static int rtw_wx_get_essid(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); - _func_enter_; if ((check_fwstate(pmlmepriv, _FW_LINKED)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { @@ -1618,7 +1575,6 @@ static int rtw_wx_get_essid(struct net_device *dev, exit: - _func_exit_; return ret; } @@ -1635,7 +1591,6 @@ static int rtw_wx_set_rate(struct net_device *dev, u32 ratevalue = 0; u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); @@ -1707,7 +1662,6 @@ set_rate: ret = -1; } -_func_exit_; return ret; } @@ -1735,7 +1689,6 @@ static int rtw_wx_set_rts(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; if (wrqu->rts.disabled) { padapter->registrypriv.rts_thresh = 2347; @@ -1749,7 +1702,6 @@ static int rtw_wx_set_rts(struct net_device *dev, DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); - _func_exit_; return 0; } @@ -1760,7 +1712,6 @@ static int rtw_wx_get_rts(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); @@ -1768,7 +1719,6 @@ static int rtw_wx_get_rts(struct net_device *dev, wrqu->rts.fixed = 0; /* no auto select */ /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ - _func_exit_; return 0; } @@ -1779,7 +1729,6 @@ static int rtw_wx_set_frag(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; if (wrqu->frag.disabled) { padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; @@ -1793,7 +1742,6 @@ static int rtw_wx_set_frag(struct net_device *dev, DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); - _func_exit_; return 0; } @@ -1804,14 +1752,12 @@ static int rtw_wx_get_frag(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); wrqu->frag.value = padapter->xmitpriv.frag_len; wrqu->frag.fixed = 0; /* no auto select */ - _func_exit_; return 0; } @@ -1845,7 +1791,6 @@ static int rtw_wx_set_enc(struct net_device *dev, key = erq->flags & IW_ENCODE_INDEX; - _func_enter_; if (erq->flags & IW_ENCODE_DISABLED) { DBG_88E("EncryptionDisabled\n"); @@ -1940,7 +1885,6 @@ static int rtw_wx_set_enc(struct net_device *dev, exit: - _func_exit_; return ret; } @@ -1954,7 +1898,6 @@ static int rtw_wx_get_enc(struct net_device *dev, struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - _func_enter_; if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { @@ -2008,7 +1951,6 @@ static int rtw_wx_get_enc(struct net_device *dev, erq->flags |= IW_ENCODE_DISABLED; break; } - _func_exit_; return ret; } diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index 57d1ff750d52..0624378efd6f 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -61,12 +61,10 @@ void rtw_init_mlme_timer(struct adapter *padapter) void rtw_os_indicate_connect(struct adapter *adapter) { -_func_enter_; rtw_indicate_wx_assoc_event(adapter); netif_carrier_on(adapter->pnetdev); if (adapter->pid[2] != 0) rtw_signal_process(adapter->pid[2], SIGALRM); -_func_exit_; } void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) @@ -119,11 +117,9 @@ void rtw_reset_securitypriv(struct adapter *adapter) void rtw_os_indicate_disconnect(struct adapter *adapter) { -_func_enter_; netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */ rtw_indicate_wx_disassoc_event(adapter); rtw_reset_securitypriv(adapter); -_func_exit_; } void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) @@ -132,7 +128,6 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) u8 *buff, *p, i; union iwreq_data wrqu; -_func_enter_; RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode=%d\n", authmode)); buff = NULL; @@ -141,7 +136,7 @@ _func_enter_; ("rtw_report_sec_ie, authmode=%d\n", authmode)); buff = rtw_malloc(IW_CUSTOM_MAX); if (!buff) - goto exit; + return; _rtw_memset(buff, 0, IW_CUSTOM_MAX); p = buff; p += sprintf(p, "ASSOCINFO(ReqIEs ="); @@ -157,8 +152,6 @@ _func_enter_; wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); kfree(buff); } -exit: -_func_exit_; } static void _survey_timer_hdl(void *FunctionContext) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 68f98fa114d2..cf4107ab80cb 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -520,7 +520,6 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) uint status = _SUCCESS; struct registry_priv *registry_par = &padapter->registrypriv; -_func_enter_; GlobalDebugLevel = rtw_debug; registry_par->chip_version = (u8)rtw_chip_version; @@ -588,7 +587,6 @@ _func_enter_; snprintf(registry_par->ifname, 16, "%s", ifname); snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; -_func_exit_; return status; } @@ -855,7 +853,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter) { u8 ret8 = _SUCCESS; -_func_enter_; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); @@ -930,7 +927,6 @@ _func_enter_; exit: RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n")); - _func_exit_; return ret8; } diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 989b7f1e5e1b..fd8ca60358f7 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -130,7 +130,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sk_buff *skb; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; precvpriv = &(padapter->recvpriv); pfree_recv_queue = &(precvpriv->free_recv_queue); @@ -216,7 +215,6 @@ _recv_indicatepkt_end: RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); -_func_exit_; return _SUCCESS; @@ -225,7 +223,6 @@ _recv_indicatepkt_drop: /* enqueue back to free_recv_queue */ rtw_free_recvframe(precv_frame, pfree_recv_queue); -_func_exit_; return _FAIL; } diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index b5c24298ed4c..6f3a609e86e6 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -162,7 +162,6 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; -_func_enter_; pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); if (pdvobjpriv == NULL) @@ -255,7 +254,6 @@ free_dvobj: pdvobjpriv = NULL; } exit: -_func_exit_; return pdvobjpriv; } @@ -263,7 +261,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) { struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf); -_func_enter_; usb_set_intfdata(usb_intf, NULL); if (dvobj) { @@ -288,7 +285,6 @@ _func_enter_; usb_put_dev(interface_to_usbdev(usb_intf)); -_func_exit_; } static void chip_by_usb_id(struct adapter *padapter, @@ -390,7 +386,6 @@ int rtw_hw_suspend(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct net_device *pnetdev = padapter->pnetdev; - _func_enter_; if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { @@ -443,7 +438,6 @@ int rtw_hw_suspend(struct adapter *padapter) } else { goto error_exit; } - _func_exit_; return 0; error_exit: @@ -456,7 +450,6 @@ int rtw_hw_resume(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct net_device *pnetdev = padapter->pnetdev; - _func_enter_; if (padapter) { /* system resume */ DBG_88E("==> rtw_hw_resume\n"); @@ -488,7 +481,6 @@ int rtw_hw_resume(struct adapter *padapter) goto error_exit; } - _func_exit_; return 0; error_exit: @@ -507,7 +499,6 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) int ret = 0; u32 start_time = jiffies; - _func_enter_; DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); @@ -564,7 +555,6 @@ exit: DBG_88E("<=== %s return %d.............. in %dms\n", __func__ , ret, rtw_get_passing_time_ms(start_time)); - _func_exit_; return ret; } @@ -588,7 +578,6 @@ int rtw_resume_process(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = NULL; int ret = -1; u32 start_time = jiffies; - _func_enter_; DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); @@ -627,7 +616,6 @@ exit: DBG_88E("<=== %s return %d.............. in %dms\n", __func__, ret, rtw_get_passing_time_ms(start_time)); - _func_exit_; return ret; } @@ -836,7 +824,6 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); struct adapter *padapter = dvobj->if1; -_func_enter_; DBG_88E("+rtw_dev_remove\n"); RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n")); @@ -855,7 +842,6 @@ _func_enter_; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); DBG_88E("-r871xu_dev_remove, done\n"); -_func_exit_; return; } diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 7e3f2fadd5bf..fb0bba85373b 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -80,7 +80,6 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct hal_data_8188e *haldata; -_func_enter_; switch (pxmitbuf->flags) { case VO_QUEUE_INX: @@ -156,8 +155,6 @@ check_completion: rtw_free_xmitbuf(pxmitpriv, pxmitbuf); tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - -_func_exit_; } u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) @@ -174,7 +171,6 @@ u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; -_func_enter_; RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); @@ -255,7 +251,6 @@ _func_enter_; exit: if (ret != _SUCCESS) rtw_free_xmitbuf(pxmitpriv, pxmitbuf); -_func_exit_; return ret; } diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 5ea00c35439b..2c8e3f72dec7 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -37,7 +37,6 @@ uint rtw_remainder_len(struct pkt_file *pfile) void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) { -_func_enter_; pfile->pkt = pktptr; pfile->cur_addr = pktptr->data; @@ -47,14 +46,12 @@ _func_enter_; pfile->cur_buffer = pfile->buf_start; -_func_exit_; } uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) { uint len = 0; -_func_enter_; len = rtw_remainder_len(pfile); len = (rlen > len) ? len : rlen; @@ -65,21 +62,17 @@ _func_enter_; pfile->cur_addr += len; pfile->pkt_len -= len; -_func_exit_; return len; } int rtw_endofpktfile(struct pkt_file *pfile) { -_func_enter_; if (pfile->pkt_len == 0) { - _func_exit_; return true; } -_func_exit_; return false; } @@ -244,7 +237,6 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); @@ -280,7 +272,6 @@ drop_packet: exit: -_func_exit_; return 0; } From 81291dd9484dd16e795ab4a69d16b401b2aa5821 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Mon, 10 Feb 2014 22:40:11 +0400 Subject: [PATCH 0125/1375] staging: sbe-2t3e3: Fix possible reuse of freed memory in timer function Do not call kfree() till timer function is finished. [This was found using grep. Compilation tested only] Signed-off-by: Kirill Tkhai CC: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sbe-2t3e3/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c index 0e32be5c2471..a6f93a43d216 100644 --- a/drivers/staging/sbe-2t3e3/module.c +++ b/drivers/staging/sbe-2t3e3/module.c @@ -122,7 +122,7 @@ static void t3e3_remove_card(struct pci_dev *pdev) struct channel *channel0 = pci_get_drvdata(pdev); struct card *card = channel0->card; - del_timer(&card->timer); + del_timer_sync(&card->timer); if (has_two_ports(channel0->pdev)) { t3e3_remove_channel(&card->channels[1]); pci_dev_put(card->channels[1].pdev); From 74c0da19c4ee842bf2ec880d4cef92858844934d Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Tue, 11 Feb 2014 21:32:44 -0800 Subject: [PATCH 0126/1375] staging/lustre/llite: remove lustre_generic_file_{read,write} It looks like lustre_generic_file_{read,write} are a holdover from 2.6.19 where generic_file_aio_read() replaced generic_file_readv() and cross-kernel interoperability was required for some period of time. Lustre has since removed support for those older kernels, but it looks like the wrappers were not deleted at that time. This patch will delete them. Pass &iocb->ki_pos as the last argument for these functions instead of crw_pos, since this is the convention for other callers. Verify that this is the same as the current crw_pos argument. This code can likely be cleaned up further in a later patch. Signed-off-by: Jinshan Xiong Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/lclient.h | 2 +- drivers/staging/lustre/lustre/llite/file.c | 4 --- .../lustre/lustre/llite/llite_internal.h | 12 +------ drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 31 +++++++------------ 5 files changed, 14 insertions(+), 37 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index 27316f7b7a70..de8f82ccb94d 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/drivers/staging/lustre/lustre/include/lclient.h @@ -118,7 +118,7 @@ struct ccc_io { }; /** - * True, if \a io is a normal io, False for other (sendfile, splice*). + * True, if \a io is a normal io, False for splice_{read,write}. * must be impementated in arch specific code. */ int cl_is_normalio(const struct lu_env *env, const struct cl_io *io); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index abf5f4611abc..4c28f39e8b18 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1091,10 +1091,6 @@ restart: down_read(&lli->lli_trunc_sem); } break; - case IO_SENDFILE: - vio->u.sendfile.cui_actor = args->u.sendfile.via_actor; - vio->u.sendfile.cui_target = args->u.sendfile.via_target; - break; case IO_SPLICE: vio->u.splice.cui_pipe = args->u.splice.via_pipe; vio->u.splice.cui_flags = args->u.splice.via_flags; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index bc17c2957943..e27efd164fe8 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -912,8 +912,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page); enum vvp_io_subtype { /** normal IO */ IO_NORMAL, - /** io called from .sendfile */ - IO_SENDFILE, /** io started from splice_{read|write} */ IO_SPLICE }; @@ -924,10 +922,6 @@ struct vvp_io { enum vvp_io_subtype cui_io_subtype; union { - struct { - read_actor_t cui_actor; - void *cui_target; - } sendfile; struct { struct pipe_inode_info *cui_pipe; unsigned int cui_flags; @@ -974,7 +968,7 @@ struct vvp_io { * IO arguments for various VFS I/O interfaces. */ struct vvp_io_args { - /** normal/sendfile/splice */ + /** normal/splice */ enum vvp_io_subtype via_io_subtype; union { @@ -983,10 +977,6 @@ struct vvp_io_args { struct iovec *via_iov; unsigned long via_nrsegs; } normal; - struct { - read_actor_t via_actor; - void *via_target; - } sendfile; struct { struct pipe_inode_info *via_pipe; unsigned int via_flags; diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index e9ba38a553cf..ca8fa4eacf66 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -135,7 +135,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, } /* - * Loop-back driver calls ->prepare_write() and ->sendfile() + * Loop-back driver calls ->prepare_write(). * methods directly, bypassing file system ->write() operation, * so cl_io has to be created here. */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 93cbfbb7e7f7..50383d365a0f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -51,7 +51,7 @@ static struct vvp_io *cl2vvp_io(const struct lu_env *env, const struct cl_io_slice *slice); /** - * True, if \a io is a normal io, False for sendfile() / splice_{read|write} + * True, if \a io is a normal io, False for splice_{read,write} */ int cl_is_normalio(const struct lu_env *env, const struct cl_io *io) { @@ -474,20 +474,6 @@ static void vvp_io_setattr_fini(const struct lu_env *env, vvp_io_fini(env, ios); } -static ssize_t lustre_generic_file_read(struct file *file, - struct ccc_io *vio, loff_t *ppos) -{ - return generic_file_aio_read(vio->cui_iocb, vio->cui_iov, - vio->cui_nrsegs, *ppos); -} - -static ssize_t lustre_generic_file_write(struct file *file, - struct ccc_io *vio, loff_t *ppos) -{ - return generic_file_aio_write(vio->cui_iocb, vio->cui_iov, - vio->cui_nrsegs, *ppos); -} - static int vvp_io_read_start(const struct lu_env *env, const struct cl_io_slice *ios) { @@ -540,8 +526,11 @@ static int vvp_io_read_start(const struct lu_env *env, file_accessed(file); switch (vio->cui_io_subtype) { case IO_NORMAL: - result = lustre_generic_file_read(file, cio, &pos); - break; + LASSERT(cio->cui_iocb->ki_pos == pos); + result = generic_file_aio_read(cio->cui_iocb, + cio->cui_iov, cio->cui_nrsegs, + cio->cui_iocb->ki_pos); + break; case IO_SPLICE: result = generic_file_splice_read(file, &pos, vio->u.splice.cui_pipe, cnt, @@ -586,7 +575,6 @@ static int vvp_io_write_start(const struct lu_env *env, struct cl_io *io = ios->cis_io; struct cl_object *obj = io->ci_obj; struct inode *inode = ccc_object_inode(obj); - struct file *file = cio->cui_fd->fd_file; ssize_t result = 0; loff_t pos = io->u.ci_wr.wr.crw_pos; size_t cnt = io->u.ci_wr.wr.crw_count; @@ -601,6 +589,8 @@ static int vvp_io_write_start(const struct lu_env *env, */ pos = io->u.ci_wr.wr.crw_pos = i_size_read(inode); cio->cui_iocb->ki_pos = pos; + } else { + LASSERT(cio->cui_iocb->ki_pos == pos); } CDEBUG(D_VFSTRACE, "write: [%lli, %lli)\n", pos, pos + (long long)cnt); @@ -608,8 +598,9 @@ static int vvp_io_write_start(const struct lu_env *env, if (cio->cui_iov == NULL) /* from a temp io in ll_cl_init(). */ result = 0; else - result = lustre_generic_file_write(file, cio, &pos); - + result = generic_file_aio_write(cio->cui_iocb, + cio->cui_iov, cio->cui_nrsegs, + cio->cui_iocb->ki_pos); if (result > 0) { if (result < cnt) io->ci_continue = 0; From 4624b5433f063a56032f959e7a6d72d8e6e735b6 Mon Sep 17 00:00:00 2001 From: Surendra Patil Date: Tue, 11 Feb 2014 23:57:22 -0800 Subject: [PATCH 0127/1375] drivers:staging:silicom Fixed extern warnings reported by checkpatch 1) Deleted bp_proc_create() declaration from bp_mod.h, because it is declared as static in bpctl_mod.c and not used anywhere. 2) checkpatch warns about WARNING: externs should be avoided in .c files because we have function declarations in bptcl_mod.c,These functions are not used anywhere else so made them static. Signed-off-by: Surendra Patil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bp_mod.h | 2 -- drivers/staging/silicom/bpctl_mod.c | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/silicom/bp_mod.h b/drivers/staging/silicom/bp_mod.h index 8154a7bf050f..9999e6eb03a4 100644 --- a/drivers/staging/silicom/bp_mod.h +++ b/drivers/staging/silicom/bp_mod.h @@ -698,5 +698,3 @@ static inline unsigned int jiffies_to_msecs(const unsigned long j) readl((void *)((a)->mem_map) + BP10GB_##reg)) #endif - -int bp_proc_create(void); diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 00b3c5157ea1..f4aea92133c8 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -117,12 +117,12 @@ static int wdt_timer(struct bpctl_dev *pbpctl_dev, int *time_left); static struct bpctl_dev *get_status_port_fn(struct bpctl_dev *pbpctl_dev); static void if_scan_init(void); -int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block); -int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block); -int bp_proc_create(void); +static int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block); +static int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block); +static int bp_proc_create(void); -int is_bypass_fn(struct bpctl_dev *pbpctl_dev); -int get_dev_idx_bsf(int bus, int slot, int func); +static int is_bypass_fn(struct bpctl_dev *pbpctl_dev); +static int get_dev_idx_bsf(int bus, int slot, int func); static int bp_get_dev_idx_bsf(struct net_device *dev, int *index) { @@ -262,7 +262,7 @@ static struct notifier_block bp_notifier_block = { .notifier_call = bp_device_event, }; -int is_bypass_fn(struct bpctl_dev *pbpctl_dev); +static int is_bypass_fn(struct bpctl_dev *pbpctl_dev); int wdt_time_left(struct bpctl_dev *pbpctl_dev); static void write_pulse(struct bpctl_dev *pbpctl_dev, @@ -4906,7 +4906,7 @@ static int get_bypass_info_fn(struct bpctl_dev *pbpctl_dev, char *dev_name, return 0; } -int get_dev_idx_bsf(int bus, int slot, int func) +static int get_dev_idx_bsf(int bus, int slot, int func) { int idx_dev = 0; for (idx_dev = 0; @@ -6786,7 +6786,7 @@ EXPORT_SYMBOL(bp_if_scan_sd); static struct proc_dir_entry *bp_procfs_dir; -int bp_proc_create(void) +static int bp_proc_create(void) { bp_procfs_dir = proc_mkdir(BP_PROC_DIR, init_net.proc_net); if (bp_procfs_dir == (struct proc_dir_entry *)0) { @@ -7414,7 +7414,7 @@ static int show_wd_autoreset(struct seq_file *m, void *v) } RW_FOPS(wd_autoreset) -int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block) +static int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block) { struct bypass_pfs_sd *current_pfs = &(pbp_device_block->bypass_pfs_set); static struct proc_dir_entry *procfs_dir; @@ -7484,7 +7484,7 @@ int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block) return ret; } -int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block) +static int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block) { struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set; From f1fe476ecb35e5f9ef62b58016fa4f71e1233bbe Mon Sep 17 00:00:00 2001 From: Surendra Patil Date: Tue, 11 Feb 2014 23:57:23 -0800 Subject: [PATCH 0128/1375] drivers:staging:silicom fixed checkpatch coding style error on macros checkpatch displays below errors for bypasslib/bp_ioctl.h file ERROR: Macros with complex values should be enclosed in parenthesis Hence added parenthesis for macros with complex values. Signed-off-by: Surendra Patil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bypasslib/bp_ioctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/silicom/bypasslib/bp_ioctl.h b/drivers/staging/silicom/bypasslib/bp_ioctl.h index 2d1ef5384436..a0fb79fd1909 100644 --- a/drivers/staging/silicom/bypasslib/bp_ioctl.h +++ b/drivers/staging/silicom/bypasslib/bp_ioctl.h @@ -51,7 +51,7 @@ #define WDT_STEP_TIME 0x10 /* BIT_4 */ #define WD_MIN_TIME_GET(desc) (desc & 0xf) -#define WD_STEP_COUNT_GET(desc) (desc>>5) & 0xf +#define WD_STEP_COUNT_GET(desc) ((desc>>5) & 0xf) typedef enum { IS_BYPASS = 1, @@ -156,7 +156,7 @@ typedef enum { } CMND_TYPE_SD; -#define SIOCGIFBYPASS SIOCDEVPRIVATE+10 +#define SIOCGIFBYPASS (SIOCDEVPRIVATE+10) struct bp_info { char prod_name[14]; From ecd56ff9d1873fb04846a5847d3c53837084fa69 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 12 Feb 2014 02:28:35 -0600 Subject: [PATCH 0129/1375] Staging: comedi: Correct a few printf format codes My static checker found some slightly inaccurate format codes in printf calls in comedi_fops.c and drivers/comedi_bond.c. It may be slightly pedantic to change them, but using the correctly corresponding format codes is probably a good idea. All but one were unsigned ints that were formatted with %i, change these to %u, and one was an int formatted with %u, we want to format this with %d. Signed-off-by: Chase Southwood Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 8 ++++---- drivers/staging/comedi/drivers/comedi_bond.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c22c617b0da1..b36b76060d03 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -297,7 +297,7 @@ static ssize_t max_read_buffer_kb_show(struct device *csdev, mutex_unlock(&dev->mutex); comedi_dev_put(dev); - return snprintf(buf, PAGE_SIZE, "%i\n", size); + return snprintf(buf, PAGE_SIZE, "%u\n", size); } static ssize_t max_read_buffer_kb_store(struct device *csdev, @@ -353,7 +353,7 @@ static ssize_t read_buffer_kb_show(struct device *csdev, mutex_unlock(&dev->mutex); comedi_dev_put(dev); - return snprintf(buf, PAGE_SIZE, "%i\n", size); + return snprintf(buf, PAGE_SIZE, "%u\n", size); } static ssize_t read_buffer_kb_store(struct device *csdev, @@ -410,7 +410,7 @@ static ssize_t max_write_buffer_kb_show(struct device *csdev, mutex_unlock(&dev->mutex); comedi_dev_put(dev); - return snprintf(buf, PAGE_SIZE, "%i\n", size); + return snprintf(buf, PAGE_SIZE, "%u\n", size); } static ssize_t max_write_buffer_kb_store(struct device *csdev, @@ -466,7 +466,7 @@ static ssize_t write_buffer_kb_show(struct device *csdev, mutex_unlock(&dev->mutex); comedi_dev_put(dev); - return snprintf(buf, PAGE_SIZE, "%i\n", size); + return snprintf(buf, PAGE_SIZE, "%u\n", size); } static ssize_t write_buffer_kb_store(struct device *csdev, diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 406aedb5382e..8450c99af8b0 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -211,7 +211,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) return -EINVAL; } - snprintf(file, sizeof(file), "/dev/comedi%u", minor); + snprintf(file, sizeof(file), "/dev/comedi%d", minor); file[sizeof(file) - 1] = 0; d = comedi_open(file); @@ -264,7 +264,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) char buf[20]; int left = MAX_BOARD_NAME - strlen(devpriv->name) - 1; - snprintf(buf, sizeof(buf), "%d:%d ", + snprintf(buf, sizeof(buf), "%u:%u ", bdev->minor, bdev->subdev); buf[sizeof(buf) - 1] = 0; strncat(devpriv->name, buf, left); From 48d68b06b201fda0b09f2eda5ee517a8f4c1a861 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 12 Feb 2014 21:30:22 +0530 Subject: [PATCH 0130/1375] staging: rtl8188eu: remove header file ethernet.h "ethernet.h" is included in three files but only "rtw_recv.c" using two macros defined in "ethernet.h", so move used macros in "rtw_recv.c" and remove "include/ethernet.h" header file and inclusion of this header file. v2: First version of this patch failed to apply. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 4 +- .../staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/ethernet.h | 42 ------------------- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 1 - 4 files changed, 3 insertions(+), 45 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/ethernet.h diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index c8491f69ccd3..4de98b622426 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -23,11 +23,13 @@ #include #include #include -#include #include #include #include +#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ +#define LLC_HEADER_SIZE 6 /* LLC Header Length */ + static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 540c5adae82c..b1b1584af1cd 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8188eu/include/ethernet.h b/drivers/staging/rtl8188eu/include/ethernet.h deleted file mode 100644 index a59f9120cd7e..000000000000 --- a/drivers/staging/rtl8188eu/include/ethernet.h +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/*! \file */ -#ifndef __INC_ETHERNET_H -#define __INC_ETHERNET_H - -#define ETHERNET_ADDRESS_LENGTH 6 /* Ethernet Address Length */ -#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ -#define LLC_HEADER_SIZE 6 /* LLC Header Length */ -#define TYPE_LENGTH_FIELD_SIZE 2 /* Type/Length Size */ -#define MINIMUM_ETHERNET_PACKET_SIZE 60 /* Min Ethernet Packet Size */ -#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /* Max Ethernet Packet Size */ - -/* Is Multicast Address? */ -#define RT_ETH_IS_MULTICAST(_addr) ((((u8 *)(_addr))[0]&0x01) != 0) -#define RT_ETH_IS_BROADCAST(_addr) ( \ - ((u8 *)(_addr))[0] == 0xff && \ - ((u8 *)(_addr))[1] == 0xff && \ - ((u8 *)(_addr))[2] == 0xff && \ - ((u8 *)(_addr))[3] == 0xff && \ - ((u8 *)(_addr))[4] == 0xff && \ - ((u8 *)(_addr))[5] == 0xff) /* Is Broadcast Address? */ - - -#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index fd8ca60358f7..3eff225a0e39 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -26,7 +26,6 @@ #include #include -#include #include /* init os related resource in struct recv_priv */ From 64539a81d02cc879ae9c3607f4e7de7423148b29 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 12 Feb 2014 15:38:41 +0530 Subject: [PATCH 0131/1375] staging: lustre: Remove duplicate inclusion of crypto.h crypto.h was included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index b9fa3b4a40db..6eda1799be8f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include From 861d2ac1db41d3c3e608ce37f162d5089d11367e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 12 Feb 2014 15:38:42 +0530 Subject: [PATCH 0132/1375] staging: rtl8821ae: Remove duplicate include phy.h was included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/trx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/trx.c b/drivers/staging/rtl8821ae/rtl8821ae/trx.c index 75ae4387fe19..f82ed5143b3e 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/trx.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/trx.c @@ -37,7 +37,7 @@ #include "trx.h" #include "led.h" #include "dm.h" -#include "phy.h" + u8 _rtl8821ae_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) { u16 fc = rtl_get_fc(skb); From 59fbe7025ad5878bc6e6a002d2818b08d9a07e38 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:05 -0500 Subject: [PATCH 0133/1375] staging/bcm: move IOCTL_BCM_REGISTER_READ_PRIVATE case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 96 +++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index f1b6de0293c8..0e63929b7b11 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -150,6 +150,55 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, return PktLen; } +static int bcm_char_ioctl_reg_read_private(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_rdm_buffer sRdmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + PCHAR temp_buff; + INT Status = STATUS_FAILURE; + UINT Bufflen; + u16 temp_value; + int bytes; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; + + if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if (IoBuffer.OutputLength > USHRT_MAX || + IoBuffer.OutputLength == 0) { + return -EINVAL; + } + + Bufflen = IoBuffer.OutputLength; + temp_value = 4 - (Bufflen % 4); + Bufflen += temp_value % 4; + + temp_buff = kmalloc(Bufflen, GFP_KERNEL); + if (!temp_buff) + return -ENOMEM; + + bytes = rdmalt(Adapter, (UINT)sRdmBuffer.Register, + (PUINT)temp_buff, Bufflen); + if (bytes > 0) { + Status = STATUS_SUCCESS; + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { + kfree(temp_buff); + return -EFAULT; + } + } else { + Status = bytes; + } + + kfree(temp_buff); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -201,50 +250,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) switch (cmd) { /* Rdms for Swin Idle... */ - case IOCTL_BCM_REGISTER_READ_PRIVATE: { - struct bcm_rdm_buffer sRdmBuffer = {0}; - PCHAR temp_buff; - UINT Bufflen; - u16 temp_value; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sRdmBuffer)) - return -EINVAL; - - if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if (IoBuffer.OutputLength > USHRT_MAX || - IoBuffer.OutputLength == 0) { - return -EINVAL; - } - - Bufflen = IoBuffer.OutputLength; - temp_value = 4 - (Bufflen % 4); - Bufflen += temp_value % 4; - - temp_buff = kmalloc(Bufflen, GFP_KERNEL); - if (!temp_buff) - return -ENOMEM; - - bytes = rdmalt(Adapter, (UINT)sRdmBuffer.Register, - (PUINT)temp_buff, Bufflen); - if (bytes > 0) { - Status = STATUS_SUCCESS; - if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { - kfree(temp_buff); - return -EFAULT; - } - } else { - Status = bytes; - } - - kfree(temp_buff); - break; - } + case IOCTL_BCM_REGISTER_READ_PRIVATE: + Status = bcm_char_ioctl_reg_read_private(argp, Adapter); + return Status; case IOCTL_BCM_REGISTER_WRITE_PRIVATE: { struct bcm_wrm_buffer sWrmBuffer = {0}; From 6827009f09d27e51aed337c11c699f7b1cfc84ce Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:11 -0500 Subject: [PATCH 0134/1375] staging/bcm: move IOCTL_BCM_REGISTER_WRITE_PRIVATE case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 89 +++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 0e63929b7b11..8779ed6b3099 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -199,6 +199,52 @@ static int bcm_char_ioctl_reg_read_private(void __user *argp, struct bcm_mini_ad return Status; } +static int bcm_char_ioctl_reg_write_private(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_wrm_buffer sWrmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + UINT uiTempVar = 0; + INT Status; + + /* Copy Ioctl Buffer structure */ + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; + + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4))) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } + + Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, + (PUINT)sWrmBuffer.Data, sizeof(ULONG)); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "WRM Done\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "WRM Failed\n"); + Status = -EFAULT; + } + return Status; +} + + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -254,46 +300,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_reg_read_private(argp, Adapter); return Status; - case IOCTL_BCM_REGISTER_WRITE_PRIVATE: { - struct bcm_wrm_buffer sWrmBuffer = {0}; - UINT uiTempVar = 0; - /* Copy Ioctl Buffer structure */ - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; - - /* Get WrmBuffer structure */ - if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; - if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1) || - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4))) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - - Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register, - (PUINT)sWrmBuffer.Data, sizeof(ULONG)); - - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Done\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Failed\n"); - Status = -EFAULT; - } - break; - } + case IOCTL_BCM_REGISTER_WRITE_PRIVATE: + Status = bcm_char_ioctl_reg_write_private(argp, Adapter); + return Status; case IOCTL_BCM_REGISTER_READ: case IOCTL_BCM_EEPROM_REGISTER_READ: { From 3195d4e0d9d6f2a51a2260abb7b21569af81f6ed Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:16 -0500 Subject: [PATCH 0135/1375] staging/bcm: move IOCTL_BCM_EEPROM_REGISTER_READ case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 127 ++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 8779ed6b3099..fcb19eaad244 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -244,6 +244,71 @@ static int bcm_char_ioctl_reg_write_private(void __user *argp, struct bcm_mini_a return Status; } +static int bcm_char_ioctl_eeprom_reg_read(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_rdm_buffer sRdmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + PCHAR temp_buff = NULL; + UINT uiTempVar = 0; + INT Status; + int bytes; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device in Idle Mode, Blocking Rdms\n"); + return -EACCES; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sRdmBuffer)) + return -EINVAL; + + if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if (IoBuffer.OutputLength > USHRT_MAX || + IoBuffer.OutputLength == 0) { + return -EINVAL; + } + + temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); + if (!temp_buff) + return STATUS_FAILURE; + + if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sRdmBuffer.Register & 0x3)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "RDM Done On invalid Address : %x Access Denied.\n", + (int)sRdmBuffer.Register); + + kfree(temp_buff); + return -EINVAL; + } + + uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; + bytes = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, + (PUINT)temp_buff, IoBuffer.OutputLength); + + if (bytes > 0) { + Status = STATUS_SUCCESS; + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { + kfree(temp_buff); + return -EFAULT; + } + } else { + Status = bytes; + } + + kfree(temp_buff); + return Status; +} static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -305,66 +370,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case IOCTL_BCM_REGISTER_READ: - case IOCTL_BCM_EEPROM_REGISTER_READ: { - struct bcm_rdm_buffer sRdmBuffer = {0}; - PCHAR temp_buff = NULL; - UINT uiTempVar = 0; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { + case IOCTL_BCM_EEPROM_REGISTER_READ: + Status = bcm_char_ioctl_eeprom_reg_read(argp, Adapter); + return Status; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle Mode, Blocking Rdms\n"); - return -EACCES; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sRdmBuffer)) - return -EINVAL; - - if (copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if (IoBuffer.OutputLength > USHRT_MAX || - IoBuffer.OutputLength == 0) { - return -EINVAL; - } - - temp_buff = kmalloc(IoBuffer.OutputLength, GFP_KERNEL); - if (!temp_buff) - return STATUS_FAILURE; - - if ((((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sRdmBuffer.Register & 0x3)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "RDM Done On invalid Address : %x Access Denied.\n", - (int)sRdmBuffer.Register); - - kfree(temp_buff); - return -EINVAL; - } - - uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK; - bytes = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register, - (PUINT)temp_buff, IoBuffer.OutputLength); - - if (bytes > 0) { - Status = STATUS_SUCCESS; - if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, bytes)) { - kfree(temp_buff); - return -EFAULT; - } - } else { - Status = bytes; - } - - kfree(temp_buff); - break; - } case IOCTL_BCM_REGISTER_WRITE: case IOCTL_BCM_EEPROM_REGISTER_WRITE: { struct bcm_wrm_buffer sWrmBuffer = {0}; From 4d4b00a968278d9187b92f5cdc2b1bf55e010bbc Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:21 -0500 Subject: [PATCH 0136/1375] staging/bcm: move IOCTL_BCM_EEPROM_REGISTER_WRITE case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 126 ++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 59 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index fcb19eaad244..c2219c544811 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -310,6 +310,70 @@ static int bcm_char_ioctl_eeprom_reg_read(void __user *argp, struct bcm_mini_ada return Status; } +static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, struct bcm_mini_adapter *Adapter, UINT cmd) +{ + struct bcm_wrm_buffer sWrmBuffer = {0}; + struct bcm_ioctl_buffer IoBuffer; + UINT uiTempVar = 0; + INT Status; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Device in Idle Mode, Blocking Wrms\n"); + return -EACCES; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(sWrmBuffer)) + return -EINVAL; + + /* Get WrmBuffer structure */ + if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || + ((ULONG)sWrmBuffer.Register & 0x3)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM Done On invalid Address : %x Access Denied.\n", + (int)sWrmBuffer.Register); + return -EINVAL; + } + + uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4)) && + (cmd == IOCTL_BCM_REGISTER_WRITE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } + + Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, + (PUINT)sWrmBuffer.Data, + sWrmBuffer.Length); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, + DBG_LVL_ALL, "WRM Done\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "WRM Failed\n"); + Status = -EFAULT; + } + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -375,66 +439,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case IOCTL_BCM_REGISTER_WRITE: - case IOCTL_BCM_EEPROM_REGISTER_WRITE: { - struct bcm_wrm_buffer sWrmBuffer = {0}; - UINT uiTempVar = 0; + case IOCTL_BCM_EEPROM_REGISTER_WRITE: + Status = bcm_char_ioctl_eeprom_reg_write(argp, Adapter, cmd); + return Status; - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle Mode, Blocking Wrms\n"); - return -EACCES; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(sWrmBuffer)) - return -EINVAL; - - /* Get WrmBuffer structure */ - if (copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if ((((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)sWrmBuffer.Register & 0x3)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM Done On invalid Address : %x Access Denied.\n", - (int)sWrmBuffer.Register); - return -EINVAL; - } - - uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK; - if (!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1) || - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - - Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register, - (PUINT)sWrmBuffer.Data, - sWrmBuffer.Length); - - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, - DBG_LVL_ALL, "WRM Done\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Failed\n"); - Status = -EFAULT; - } - break; - } case IOCTL_BCM_GPIO_SET_REQUEST: { UCHAR ucResetValue[4]; UINT value = 0; From f494a916d3bed992e1275157eeaf709d8383aa27 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:26 -0500 Subject: [PATCH 0137/1375] staging/bcm: move IOCTL_BCM_GPIO_SET_REQUEST case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 215 ++++++++++++++++++---------------- 1 file changed, 111 insertions(+), 104 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index c2219c544811..a7991289c7c1 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -374,6 +374,114 @@ static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, struct bcm_mini_ad return Status; } +static int bcm_char_ioctl_gpio_set_request(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_info gpio_info = {0}; + struct bcm_ioctl_buffer IoBuffer; + UCHAR ucResetValue[4]; + UINT value = 0; + UINT uiBit = 0; + UINT uiOperation = 0; + INT Status; + int bytes; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "GPIO Can't be set/clear in Low power Mode"); + return -EACCES; + } + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; + + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + uiBit = gpio_info.uiGpioNumber; + uiOperation = gpio_info.uiGpioValue; + value = (1< is not correspond to LED !!!", + value); + return -EINVAL; + } + + /* Set - setting 1 */ + if (uiOperation) { + /* Set the gpio output register */ + Status = wrmaltWithLock(Adapter, + BCM_GPIO_OUTPUT_SET_REG, + (PUINT)(&value), sizeof(UINT)); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Set the GPIO bit\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Failed to set the %dth GPIO\n", + uiBit); + return Status; + } + } else { + /* Set the gpio output register */ + Status = wrmaltWithLock(Adapter, + BCM_GPIO_OUTPUT_CLR_REG, + (PUINT)(&value), sizeof(UINT)); + + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Set the GPIO bit\n"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Failed to clear the %dth GPIO\n", + uiBit); + return Status; + } + } + + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, + (PUINT)ucResetValue, sizeof(UINT)); + if (bytes < 0) { + Status = bytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "GPIO_MODE_REGISTER read failed"); + return Status; + } else { + Status = STATUS_SUCCESS; + } + + /* Set the gpio mode register to output */ + *(UINT *)ucResetValue |= (1<private_data; @@ -443,110 +551,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_eeprom_reg_write(argp, Adapter, cmd); return Status; - case IOCTL_BCM_GPIO_SET_REQUEST: { - UCHAR ucResetValue[4]; - UINT value = 0; - UINT uiBit = 0; - UINT uiOperation = 0; - struct bcm_gpio_info gpio_info = {0}; - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "GPIO Can't be set/clear in Low power Mode"); - return -EACCES; - } - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; - - if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - uiBit = gpio_info.uiGpioNumber; - uiOperation = gpio_info.uiGpioValue; - value = (1< is not correspond to LED !!!", - value); - Status = -EINVAL; - break; - } - - /* Set - setting 1 */ - if (uiOperation) { - /* Set the gpio output register */ - Status = wrmaltWithLock(Adapter, - BCM_GPIO_OUTPUT_SET_REG, - (PUINT)(&value), sizeof(UINT)); - - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Set the GPIO bit\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Failed to set the %dth GPIO\n", - uiBit); - break; - } - } else { - /* Set the gpio output register */ - Status = wrmaltWithLock(Adapter, - BCM_GPIO_OUTPUT_CLR_REG, - (PUINT)(&value), sizeof(UINT)); - - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Set the GPIO bit\n"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Failed to clear the %dth GPIO\n", - uiBit); - break; - } - } - - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, - (PUINT)ucResetValue, sizeof(UINT)); - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "GPIO_MODE_REGISTER read failed"); - break; - } else { - Status = STATUS_SUCCESS; - } - - /* Set the gpio mode register to output */ - *(UINT *)ucResetValue |= (1< Date: Thu, 13 Feb 2014 14:45:31 -0500 Subject: [PATCH 0138/1375] staging/bcm: move BCM_LED_THREAD_STATE_CHANGE_REQ case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 95 +++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index a7991289c7c1..c0b29971dd72 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -482,6 +482,54 @@ static int bcm_char_ioctl_gpio_set_request(void __user *argp, struct bcm_mini_ad return Status; } +static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_user_thread_req threadReq = {0}; + struct bcm_ioctl_buffer IoBuffer; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "User made LED thread InActive"); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "GPIO Can't be set/clear in Low power Mode"); + return -EACCES; + } + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(threadReq)) + return -EINVAL; + + if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + /* if LED thread is running(Actively or Inactively) set it state to make inactive */ + if (Adapter->LEDInfo.led_thread_running) { + if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "Activating thread req"); + Adapter->DriverState = LED_THREAD_ACTIVE; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + OSAL_DBG, DBG_LVL_ALL, + "DeActivating Thread req....."); + Adapter->DriverState = LED_THREAD_INACTIVE; + } + + /* signal thread. */ + wake_up(&Adapter->LEDInfo.notify_led_event); + } + return STATUS_SUCCESS; +} + + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -555,50 +603,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_gpio_set_request(argp, Adapter); return Status; - case BCM_LED_THREAD_STATE_CHANGE_REQ: { - struct bcm_user_thread_req threadReq = {0}; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "User made LED thread InActive"); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "GPIO Can't be set/clear in Low power Mode"); - Status = -EACCES; - break; - } - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(threadReq)) - return -EINVAL; - - if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - /* if LED thread is running(Actively or Inactively) set it state to make inactive */ - if (Adapter->LEDInfo.led_thread_running) { - if (threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Activating thread req"); - Adapter->DriverState = LED_THREAD_ACTIVE; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "DeActivating Thread req....."); - Adapter->DriverState = LED_THREAD_INACTIVE; - } - - /* signal thread. */ - wake_up(&Adapter->LEDInfo.notify_led_event); - } - } - break; + case BCM_LED_THREAD_STATE_CHANGE_REQ: + Status = bcm_char_ioctl_led_thread_state_change_req(argp, Adapter); + return Status; case IOCTL_BCM_GPIO_STATUS_REQUEST: { ULONG uiBit = 0; From 3eedb5fa71f38bdb07491af8b65da27d48dd0f3b Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:36 -0500 Subject: [PATCH 0139/1375] staging/bcm: move IOCTL_BCM_GPIO_STATUS_REQUEST case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 78 +++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index c0b29971dd72..56b445abedf8 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -529,6 +529,46 @@ static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, struct return STATUS_SUCCESS; } +static int bcm_char_ioctl_gpio_status_request(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_info gpio_info = {0}; + struct bcm_ioctl_buffer IoBuffer; + ULONG uiBit = 0; + UCHAR ucRead[4]; + INT Status; + int bytes; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EACCES; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_info)) + return -EINVAL; + + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + uiBit = gpio_info.uiGpioNumber; + + /* Set the gpio output register */ + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, + (PUINT)ucRead, sizeof(UINT)); + + if (bytes < 0) { + Status = bytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "RDM Failed\n"); + return Status; + } else { + Status = STATUS_SUCCESS; + } + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -607,41 +647,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_led_thread_state_change_req(argp, Adapter); return Status; - case IOCTL_BCM_GPIO_STATUS_REQUEST: { - ULONG uiBit = 0; - UCHAR ucRead[4]; - struct bcm_gpio_info gpio_info = {0}; - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EACCES; - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_info)) - return -EINVAL; - - if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - uiBit = gpio_info.uiGpioNumber; - - /* Set the gpio output register */ - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, - (PUINT)ucRead, sizeof(UINT)); - - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "RDM Failed\n"); - return Status; - } else { - Status = STATUS_SUCCESS; - } - } - break; + case IOCTL_BCM_GPIO_STATUS_REQUEST: + Status = bcm_char_ioctl_gpio_status_request(argp, Adapter); + return Status; case IOCTL_BCM_GPIO_MULTI_REQUEST: { UCHAR ucResetValue[4]; From 3903246c417b01514cf949477a2235f6928dd633 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:41 -0500 Subject: [PATCH 0140/1375] staging/bcm: move IOCTL_BCM_GPIO_MULTI_REQUEST case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 183 ++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 88 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 56b445abedf8..e69315833a08 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -569,6 +569,98 @@ static int bcm_char_ioctl_gpio_status_request(void __user *argp, struct bcm_mini return Status; } +static int bcm_char_ioctl_gpio_multi_request(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; + struct bcm_gpio_multi_info *pgpio_multi_info = (struct bcm_gpio_multi_info *)gpio_multi_info; + struct bcm_ioctl_buffer IoBuffer; + UCHAR ucResetValue[4]; + INT Status = STATUS_FAILURE; + int bytes; + + memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info)); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EINVAL; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_multi_info)) + return -EINVAL; + + if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, + "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", + pgpio_multi_info[WIMAX_IDX].uiGPIOMask, + Adapter->gpioBitMap); + return -EINVAL; + } + + /* Set the gpio output register */ + if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & + (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { + /* Set 1's in GPIO OUTPUT REGISTER */ + *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & + pgpio_multi_info[WIMAX_IDX].uiGPIOValue; + + if (*(UINT *) ucResetValue) + Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, + (PUINT)ucResetValue, sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); + return Status; + } + + /* Clear to 0's in GPIO OUTPUT REGISTER */ + *(UINT *)ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & + (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); + + if (*(UINT *) ucResetValue) + Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); + return Status; + } + } + + if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + + if (bytes < 0) { + Status = bytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "RDM to GPIO_PIN_STATE_REGISTER Failed."); + return Status; + } else { + Status = STATUS_SUCCESS; + } + + pgpio_multi_info[WIMAX_IDX].uiGPIOValue = (*(UINT *)ucResetValue & + pgpio_multi_info[WIMAX_IDX].uiGPIOMask); + } + + Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed while copying Content to IOBufer for user space err:%d", Status); + return -EFAULT; + } + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -651,94 +743,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_gpio_status_request(argp, Adapter); return Status; - case IOCTL_BCM_GPIO_MULTI_REQUEST: { - UCHAR ucResetValue[4]; - struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; - struct bcm_gpio_multi_info *pgpio_multi_info = (struct bcm_gpio_multi_info *)gpio_multi_info; - - memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info)); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EINVAL; - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_multi_info)) - return -EINVAL; - - if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", - pgpio_multi_info[WIMAX_IDX].uiGPIOMask, - Adapter->gpioBitMap); - Status = -EINVAL; - break; - } - - /* Set the gpio output register */ - if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & - (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { - /* Set 1's in GPIO OUTPUT REGISTER */ - *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - pgpio_multi_info[WIMAX_IDX].uiGPIOValue; - - if (*(UINT *) ucResetValue) - Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, - (PUINT)ucResetValue, sizeof(ULONG)); - - if (Status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); - return Status; - } - - /* Clear to 0's in GPIO OUTPUT REGISTER */ - *(UINT *)ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); - - if (*(UINT *) ucResetValue) - Status = wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, (PUINT)ucResetValue, sizeof(ULONG)); - - if (Status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); - return Status; - } - } - - if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); - - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "RDM to GPIO_PIN_STATE_REGISTER Failed."); - return Status; - } else { - Status = STATUS_SUCCESS; - } - - pgpio_multi_info[WIMAX_IDX].uiGPIOValue = (*(UINT *)ucResetValue & - pgpio_multi_info[WIMAX_IDX].uiGPIOMask); - } - - Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Failed while copying Content to IOBufer for user space err:%d", Status); - return -EFAULT; - } - } - break; + case IOCTL_BCM_GPIO_MULTI_REQUEST: + Status = bcm_char_ioctl_gpio_multi_request(argp, Adapter); + return Status; case IOCTL_BCM_GPIO_MODE_REQUEST: { UCHAR ucResetValue[4]; From e2d94d261e7ffce29af31086703fd5aa03653c43 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:47 -0500 Subject: [PATCH 0141/1375] staging/bcm: move IOCTL_BCM_GPIO_MODE_REQUEST case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 156 +++++++++++++++++----------------- 1 file changed, 80 insertions(+), 76 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index e69315833a08..eaf8eb5d4f87 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -661,6 +661,83 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, struct bcm_mini_ return Status; } +static int bcm_char_ioctl_gpio_mode_request(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; + struct bcm_gpio_multi_mode *pgpio_multi_mode = (struct bcm_gpio_multi_mode *)gpio_multi_mode; + struct bcm_ioctl_buffer IoBuffer; + UCHAR ucResetValue[4]; + INT Status; + int bytes; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) + return -EINVAL; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) + return -EINVAL; + + if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) + return -EFAULT; + + bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); + + if (bytes < 0) { + Status = bytes; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read of GPIO_MODE_REGISTER failed"); + return Status; + } else { + Status = STATUS_SUCCESS; + } + + /* Validating the request */ + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); + return -EINVAL; + } + + if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { + /* write all OUT's (1's) */ + *(UINT *) ucResetValue |= (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + + /* write all IN's (0's) */ + *(UINT *) ucResetValue &= ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & + pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); + + /* Currently implemented return the modes of all GPIO's + * else needs to bit AND with mask + */ + pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + + Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(ULONG)); + if (Status == STATUS_SUCCESS) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "WRM to GPIO_MODE_REGISTER Done"); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "WRM to GPIO_MODE_REGISTER Failed"); + return -EFAULT; + } + } else { + /* if uiGPIOMask is 0 then return mode register configuration */ + pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; + } + + Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Failed while copying Content to IOBufer for user space err:%d", Status); + return -EFAULT; + } + return Status; +} static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -670,7 +747,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) INT Status = STATUS_FAILURE; int timeout = 0; struct bcm_ioctl_buffer IoBuffer; - int bytes; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", @@ -747,81 +823,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_gpio_multi_request(argp, Adapter); return Status; - case IOCTL_BCM_GPIO_MODE_REQUEST: { - UCHAR ucResetValue[4]; - struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; - struct bcm_gpio_multi_mode *pgpio_multi_mode = (struct bcm_gpio_multi_mode *)gpio_multi_mode; - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) - return -EINVAL; - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) - return -EINVAL; - - if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) - return -EFAULT; - - bytes = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(UINT)); - - if (bytes < 0) { - Status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read of GPIO_MODE_REGISTER failed"); - return Status; - } else { - Status = STATUS_SUCCESS; - } - - /* Validating the request */ - if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask, Adapter->gpioBitMap); - Status = -EINVAL; - break; - } - - if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { - /* write all OUT's (1's) */ - *(UINT *) ucResetValue |= (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); - - /* write all IN's (0's) */ - *(UINT *) ucResetValue &= ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); - - /* Currently implemented return the modes of all GPIO's - * else needs to bit AND with mask - */ - pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; - - Status = wrmaltWithLock(Adapter, GPIO_MODE_REGISTER, (PUINT)ucResetValue, sizeof(ULONG)); - if (Status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "WRM to GPIO_MODE_REGISTER Done"); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "WRM to GPIO_MODE_REGISTER Failed"); - Status = -EFAULT; - break; - } - } else { -/* if uiGPIOMask is 0 then return mode register configuration */ - pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT *)ucResetValue; - } - - Status = copy_to_user(IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Failed while copying Content to IOBufer for user space err:%d", Status); - return -EFAULT; - } - } - break; + case IOCTL_BCM_GPIO_MODE_REQUEST: + Status = bcm_char_ioctl_gpio_mode_request(argp, Adapter); + return Status; case IOCTL_MAC_ADDR_REQ: case IOCTL_LINK_REQ: From 0566ee9536c29e6eca0b0f9191f9ea3585a7ea46 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:52 -0500 Subject: [PATCH 0142/1375] staging/bcm: move several request ioctl cases out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 84 +++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index eaf8eb5d4f87..9b9bc5b09693 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -739,6 +739,49 @@ static int bcm_char_ioctl_gpio_mode_request(void __user *argp, struct bcm_mini_a return Status; } +static int bcm_char_ioctl_misc_request(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + PVOID pvBuffer = NULL; + INT Status; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength < sizeof(struct bcm_link_request)) + return -EINVAL; + + if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) + return -EINVAL; + + pvBuffer = memdup_user(IoBuffer.InputBuffer, + IoBuffer.InputLength); + if (IS_ERR(pvBuffer)) + return PTR_ERR(pvBuffer); + + down(&Adapter->LowPowerModeSync); + Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, + !Adapter->bPreparingForLowPowerMode, + (1 * HZ)); + if (Status == -ERESTARTSYS) + goto cntrlEnd; + + if (Adapter->bPreparingForLowPowerMode) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Preparing Idle Mode is still True - Hence Rejecting control message\n"); + Status = STATUS_FAILURE; + goto cntrlEnd; + } + Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); + +cntrlEnd: + up(&Adapter->LowPowerModeSync); + kfree(pvBuffer); + return Status; +} + + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -832,44 +875,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_CM_REQUEST: case IOCTL_SS_INFO_REQ: case IOCTL_SEND_CONTROL_MESSAGE: - case IOCTL_IDLE_REQ: { - PVOID pvBuffer = NULL; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength < sizeof(struct bcm_link_request)) - return -EINVAL; - - if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) - return -EINVAL; - - pvBuffer = memdup_user(IoBuffer.InputBuffer, - IoBuffer.InputLength); - if (IS_ERR(pvBuffer)) - return PTR_ERR(pvBuffer); - - down(&Adapter->LowPowerModeSync); - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, - !Adapter->bPreparingForLowPowerMode, - (1 * HZ)); - if (Status == -ERESTARTSYS) - goto cntrlEnd; - - if (Adapter->bPreparingForLowPowerMode) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Preparing Idle Mode is still True - Hence Rejecting control message\n"); - Status = STATUS_FAILURE; - goto cntrlEnd; - } - Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer); - -cntrlEnd: - up(&Adapter->LowPowerModeSync); - kfree(pvBuffer); - break; - } + case IOCTL_IDLE_REQ: + Status = bcm_char_ioctl_misc_request(argp, Adapter); + return Status; case IOCTL_BCM_BUFFER_DOWNLOAD_START: { if (down_trylock(&Adapter->NVMRdmWrmLock)) { From 79f99494892c8bd7e7464ee273d8a43fc08c406d Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:45:57 -0500 Subject: [PATCH 0143/1375] staging/bcm: move IOCTL_BCM_BUFFER_DOWNLOAD_START case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 67 +++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 9b9bc5b09693..9b4284078255 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -781,6 +781,41 @@ cntrlEnd: return Status; } +static int bcm_char_ioctl_buffer_download_start(struct bcm_mini_adapter *Adapter) +{ + INT Status; + + if (down_trylock(&Adapter->NVMRdmWrmLock)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); + return -EACCES; + } + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Starting the firmware download PID =0x%x!!!!\n", current->pid); + + if (down_trylock(&Adapter->fw_download_sema)) + return -EBUSY; + + Adapter->bBinDownloaded = false; + Adapter->fw_download_process_pid = current->pid; + Adapter->bCfgDownloaded = false; + Adapter->fw_download_done = false; + netif_carrier_off(Adapter->dev); + netif_stop_queue(Adapter->dev); + Status = reset_card_proc(Adapter); + if (Status) { + pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + return Status; + } + mdelay(10); + + up(&Adapter->NVMRdmWrmLock); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -879,37 +914,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_misc_request(argp, Adapter); return Status; - case IOCTL_BCM_BUFFER_DOWNLOAD_START: { - if (down_trylock(&Adapter->NVMRdmWrmLock)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Starting the firmware download PID =0x%x!!!!\n", current->pid); - - if (down_trylock(&Adapter->fw_download_sema)) - return -EBUSY; - - Adapter->bBinDownloaded = false; - Adapter->fw_download_process_pid = current->pid; - Adapter->bCfgDownloaded = false; - Adapter->fw_download_done = false; - netif_carrier_off(Adapter->dev); - netif_stop_queue(Adapter->dev); - Status = reset_card_proc(Adapter); - if (Status) { - pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name); - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - return Status; - } - mdelay(10); - - up(&Adapter->NVMRdmWrmLock); + case IOCTL_BCM_BUFFER_DOWNLOAD_START: + Status = bcm_char_ioctl_buffer_download_start(Adapter); return Status; - } case IOCTL_BCM_BUFFER_DOWNLOAD: { struct bcm_firmware_info *psFwInfo = NULL; From d9db71bdd3a28431b724d7790d40c4dffd63bed8 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:02 -0500 Subject: [PATCH 0144/1375] staging/bcm: move IOCTL_BCM_BUFFER_DOWNLOAD case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 151 ++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 72 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 9b4284078255..2edf85ea6af6 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -816,6 +816,83 @@ static int bcm_char_ioctl_buffer_download_start(struct bcm_mini_adapter *Adapter return Status; } +static int bcm_char_ioctl_buffer_download(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_firmware_info *psFwInfo = NULL; + struct bcm_ioctl_buffer IoBuffer; + INT Status; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); + + if (!down_trylock(&Adapter->fw_download_sema)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Invalid way to download buffer. Use Start and then call this!!!\n"); + up(&Adapter->fw_download_sema); + return -EINVAL; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { + up(&Adapter->fw_download_sema); + return -EFAULT; + } + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Length for FW DLD is : %lx\n", IoBuffer.InputLength); + + if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) { + up(&Adapter->fw_download_sema); + return -EINVAL; + } + + psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); + if (!psFwInfo) { + up(&Adapter->fw_download_sema); + return -ENOMEM; + } + + if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) { + up(&Adapter->fw_download_sema); + kfree(psFwInfo); + return -EFAULT; + } + + if (!psFwInfo->pvMappedFirmwareAddress || + (psFwInfo->u32FirmwareLength == 0)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", + psFwInfo->u32FirmwareLength); + up(&Adapter->fw_download_sema); + kfree(psFwInfo); + Status = -EINVAL; + return Status; + } + + Status = bcm_ioctl_fw_download(Adapter, psFwInfo); + + if (Status != STATUS_SUCCESS) { + if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); + else + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n"); + + /* up(&Adapter->fw_download_sema); */ + + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = DRIVER_INIT; + Adapter->LEDInfo.bLedInitDone = false; + wake_up(&Adapter->LEDInfo.notify_led_event); + } + } + + if (Status != STATUS_SUCCESS) + up(&Adapter->fw_download_sema); + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); + kfree(psFwInfo); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -918,79 +995,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_buffer_download_start(Adapter); return Status; - case IOCTL_BCM_BUFFER_DOWNLOAD: { - struct bcm_firmware_info *psFwInfo = NULL; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid); - - if (!down_trylock(&Adapter->fw_download_sema)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Invalid way to download buffer. Use Start and then call this!!!\n"); - up(&Adapter->fw_download_sema); - Status = -EINVAL; - return Status; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { - up(&Adapter->fw_download_sema); - return -EFAULT; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Length for FW DLD is : %lx\n", IoBuffer.InputLength); - - if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) { - up(&Adapter->fw_download_sema); - return -EINVAL; - } - - psFwInfo = kmalloc(sizeof(*psFwInfo), GFP_KERNEL); - if (!psFwInfo) { - up(&Adapter->fw_download_sema); - return -ENOMEM; - } - - if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) { - up(&Adapter->fw_download_sema); - kfree(psFwInfo); - return -EFAULT; - } - - if (!psFwInfo->pvMappedFirmwareAddress || - (psFwInfo->u32FirmwareLength == 0)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n", - psFwInfo->u32FirmwareLength); - up(&Adapter->fw_download_sema); - kfree(psFwInfo); - Status = -EINVAL; - return Status; - } - - Status = bcm_ioctl_fw_download(Adapter, psFwInfo); - - if (Status != STATUS_SUCCESS) { - if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n"); - else - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n"); - - /* up(&Adapter->fw_download_sema); */ - - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = DRIVER_INIT; - Adapter->LEDInfo.bLedInitDone = false; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - } - - if (Status != STATUS_SUCCESS) - up(&Adapter->fw_download_sema); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n"); - kfree(psFwInfo); + case IOCTL_BCM_BUFFER_DOWNLOAD: + Status = bcm_char_ioctl_buffer_download(argp, Adapter); return Status; - } case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: { if (!down_trylock(&Adapter->fw_download_sema)) { From 49444b558d6c19cb6d6e76c689b33bf6dd7071e8 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:07 -0500 Subject: [PATCH 0145/1375] staging/bcm: move IOCTL_BCM_BUFFER_DOWNLOAD_STOP case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 134 ++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 2edf85ea6af6..9db4ec9d1983 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -893,6 +893,74 @@ static int bcm_char_ioctl_buffer_download(void __user *argp, struct bcm_mini_ada return Status; } +static int bcm_char_ioctl_buffer_download_stop(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + INT Status; + int timeout = 0; + + if (!down_trylock(&Adapter->fw_download_sema)) { + up(&Adapter->fw_download_sema); + return -EINVAL; + } + + if (down_trylock(&Adapter->NVMRdmWrmLock)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "FW download blocked as EEPROM Read/Write is in progress\n"); + up(&Adapter->fw_download_sema); + return -EACCES; + } + + Adapter->bBinDownloaded = TRUE; + Adapter->bCfgDownloaded = TRUE; + atomic_set(&Adapter->CurrNumFreeTxDesc, 0); + Adapter->CurrNumRecvDescs = 0; + Adapter->downloadDDR = 0; + + /* setting the Mips to Run */ + Status = run_card_proc(Adapter); + + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n"); + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + return Status; + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, + DBG_LVL_ALL, "Firm Download Over...\n"); + } + + mdelay(10); + + /* Wait for MailBox Interrupt */ + if (StartInterruptUrb((struct bcm_interface_adapter *)Adapter->pvInterfaceAdapter)) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); + + timeout = 5*HZ; + Adapter->waiting_to_fw_download_done = false; + wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, + Adapter->waiting_to_fw_download_done, timeout); + Adapter->fw_download_process_pid = INVALID_PID; + Adapter->fw_download_done = TRUE; + atomic_set(&Adapter->CurrNumFreeTxDesc, 0); + Adapter->CurrNumRecvDescs = 0; + Adapter->PrevNumRecvDescs = 0; + atomic_set(&Adapter->cntrlpktCnt, 0); + Adapter->LinkUpStatus = 0; + Adapter->LinkStatus = 0; + + if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { + Adapter->DriverState = FW_DOWNLOAD_DONE; + wake_up(&Adapter->LEDInfo.notify_led_event); + } + + if (!timeout) + Status = -ENODEV; + + up(&Adapter->fw_download_sema); + up(&Adapter->NVMRdmWrmLock); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -900,7 +968,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) void __user *argp = (void __user *)arg; struct bcm_mini_adapter *Adapter = pTarang->Adapter; INT Status = STATUS_FAILURE; - int timeout = 0; struct bcm_ioctl_buffer IoBuffer; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, @@ -999,69 +1066,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_buffer_download(argp, Adapter); return Status; - case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: { - if (!down_trylock(&Adapter->fw_download_sema)) { - up(&Adapter->fw_download_sema); - return -EINVAL; - } - - if (down_trylock(&Adapter->NVMRdmWrmLock)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "FW download blocked as EEPROM Read/Write is in progress\n"); - up(&Adapter->fw_download_sema); - return -EACCES; - } - - Adapter->bBinDownloaded = TRUE; - Adapter->bCfgDownloaded = TRUE; - atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - Adapter->CurrNumRecvDescs = 0; - Adapter->downloadDDR = 0; - - /* setting the Mips to Run */ - Status = run_card_proc(Adapter); - - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n"); - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); - return Status; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "Firm Download Over...\n"); - } - - mdelay(10); - - /* Wait for MailBox Interrupt */ - if (StartInterruptUrb((struct bcm_interface_adapter *)Adapter->pvInterfaceAdapter)) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n"); - - timeout = 5*HZ; - Adapter->waiting_to_fw_download_done = false; - wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue, - Adapter->waiting_to_fw_download_done, timeout); - Adapter->fw_download_process_pid = INVALID_PID; - Adapter->fw_download_done = TRUE; - atomic_set(&Adapter->CurrNumFreeTxDesc, 0); - Adapter->CurrNumRecvDescs = 0; - Adapter->PrevNumRecvDescs = 0; - atomic_set(&Adapter->cntrlpktCnt, 0); - Adapter->LinkUpStatus = 0; - Adapter->LinkStatus = 0; - - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = FW_DOWNLOAD_DONE; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - - if (!timeout) - Status = -ENODEV; - - up(&Adapter->fw_download_sema); - up(&Adapter->NVMRdmWrmLock); + case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: + Status = bcm_char_ioctl_buffer_download_stop(argp, Adapter); return Status; - } + case IOCTL_BE_BUCKET_SIZE: Status = 0; From 6e5781c67dfc0946cb53baa0cb034a12925911dd Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:12 -0500 Subject: [PATCH 0146/1375] staging/bcm: move IOCTL_CHIP_RESET case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 9db4ec9d1983..a03ba2ec02f8 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -961,6 +961,26 @@ static int bcm_char_ioctl_buffer_download_stop(void __user *argp, struct bcm_min return Status; } +static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *Adapter) +{ + INT Status; + INT NVMAccess; + + NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); + if (NVMAccess) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); + return -EACCES; + } + + down(&Adapter->RxAppControlQueuelock); + Status = reset_card_proc(Adapter); + flushAllAppQ(); + up(&Adapter->RxAppControlQueuelock); + up(&Adapter->NVMRdmWrmLock); + ResetCounters(Adapter); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1083,21 +1103,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = -EFAULT; break; - case IOCTL_CHIP_RESET: { - INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - if (NVMAccess) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } - - down(&Adapter->RxAppControlQueuelock); - Status = reset_card_proc(Adapter); - flushAllAppQ(); - up(&Adapter->RxAppControlQueuelock); - up(&Adapter->NVMRdmWrmLock); - ResetCounters(Adapter); - break; - } + case IOCTL_CHIP_RESET: + Status = bcm_char_ioctl_chip_reset(Adapter); + return Status; case IOCTL_QOS_THRESHOLD: { USHORT uiLoopIndex; From 645926b3139d5989fb92c0982cf49b071291c9a4 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:17 -0500 Subject: [PATCH 0147/1375] staging/bcm: move IOCTL_QOS_THRESHOLD case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index a03ba2ec02f8..5dc9f71189fe 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -981,6 +981,19 @@ static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *Adapter) return Status; } +static int bcm_char_ioctl_qos_threshold(ULONG arg, struct bcm_mini_adapter *Adapter) +{ + USHORT uiLoopIndex; + + for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { + if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, + (unsigned long __user *)arg)) { + return -EFAULT; + } + } + return 0; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1107,19 +1120,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_chip_reset(Adapter); return Status; - case IOCTL_QOS_THRESHOLD: { - USHORT uiLoopIndex; - - Status = 0; - for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { - if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold, - (unsigned long __user *)arg)) { - Status = -EFAULT; - break; - } - } - break; - } + case IOCTL_QOS_THRESHOLD: + Status = bcm_char_ioctl_qos_threshold(arg, Adapter); + return Status; case IOCTL_DUMP_PACKET_INFO: DumpPackInfo(Adapter); From a0ad961a2777b27ef529097449b5dfff5195e5f0 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:22 -0500 Subject: [PATCH 0148/1375] staging/bcm: move IOCTL_BCM_SWITCH_TRANSFER_MODE case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 5dc9f71189fe..9d8048feae23 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -994,6 +994,25 @@ static int bcm_char_ioctl_qos_threshold(ULONG arg, struct bcm_mini_adapter *Adap return 0; } +static int bcm_char_ioctl_switch_transfer_mode(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + UINT uiData = 0; + + if (copy_from_user(&uiData, argp, sizeof(UINT))) + return -EFAULT; + + if (uiData) { + /* Allow All Packets */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); + Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; + } else { + /* Allow IP only Packets */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); + Adapter->TransferMode = IP_PACKET_ONLY_MODE; + } + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1136,23 +1155,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = STATUS_SUCCESS; break; - case IOCTL_BCM_SWITCH_TRANSFER_MODE: { - UINT uiData = 0; - if (copy_from_user(&uiData, argp, sizeof(UINT))) - return -EFAULT; - - if (uiData) { - /* Allow All Packets */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); - Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE; - } else { - /* Allow IP only Packets */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); - Adapter->TransferMode = IP_PACKET_ONLY_MODE; - } - Status = STATUS_SUCCESS; - break; - } + case IOCTL_BCM_SWITCH_TRANSFER_MODE: + Status = bcm_char_ioctl_switch_transfer_mode(argp, Adapter); + return Status; case IOCTL_BCM_GET_DRIVER_VERSION: { ulong len; From dfb442d455abf50149a55b25f1c58a46806100c0 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:27 -0500 Subject: [PATCH 0149/1375] staging/bcm: move IOCTL_BCM_GET_DRIVER_VERSION case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 9d8048feae23..17d2a3f941f5 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1013,6 +1013,23 @@ static int bcm_char_ioctl_switch_transfer_mode(void __user *argp, struct bcm_min return STATUS_SUCCESS; } +static int bcm_char_ioctl_get_driver_version(void __user *argp) +{ + struct bcm_ioctl_buffer IoBuffer; + ulong len; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); + + if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) + return -EFAULT; + + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1159,20 +1176,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_switch_transfer_mode(argp, Adapter); return Status; - case IOCTL_BCM_GET_DRIVER_VERSION: { - ulong len; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); - - if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) - return -EFAULT; - Status = STATUS_SUCCESS; - break; - } + case IOCTL_BCM_GET_DRIVER_VERSION: + Status = bcm_char_ioctl_get_driver_version(argp); + return Status; case IOCTL_BCM_GET_CURRENT_STATUS: { struct bcm_link_state link_state; From 9c434f8e23c29c8cd2ff88048ca6508e9d3ed360 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:32 -0500 Subject: [PATCH 0150/1375] staging/bcm: move IOCTL_BCM_GET_CURRENT_STATUS case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 55 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 17d2a3f941f5..da8443574643 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1030,6 +1030,32 @@ static int bcm_char_ioctl_get_driver_version(void __user *argp) return STATUS_SUCCESS; } +static int bcm_char_ioctl_get_current_status(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_link_state link_state; + struct bcm_ioctl_buffer IoBuffer; + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); + return -EFAULT; + } + + if (IoBuffer.OutputLength != sizeof(link_state)) + return -EINVAL; + + memset(&link_state, 0, sizeof(link_state)); + link_state.bIdleMode = Adapter->IdleMode; + link_state.bShutdownMode = Adapter->bShutStatus; + link_state.ucLinkStatus = Adapter->LinkStatus; + + if (copy_to_user(IoBuffer.OutputBuffer, &link_state, min_t(size_t, sizeof(link_state), IoBuffer.OutputLength))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); + return -EFAULT; + } + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1180,32 +1206,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_get_driver_version(argp); return Status; - case IOCTL_BCM_GET_CURRENT_STATUS: { - struct bcm_link_state link_state; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n"); - return -EFAULT; - } - - if (IoBuffer.OutputLength != sizeof(link_state)) { - Status = -EINVAL; - break; - } - - memset(&link_state, 0, sizeof(link_state)); - link_state.bIdleMode = Adapter->IdleMode; - link_state.bShutdownMode = Adapter->bShutStatus; - link_state.ucLinkStatus = Adapter->LinkStatus; - - if (copy_to_user(IoBuffer.OutputBuffer, &link_state, min_t(size_t, sizeof(link_state), IoBuffer.OutputLength))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n"); - return -EFAULT; - } - Status = STATUS_SUCCESS; - break; - } + case IOCTL_BCM_GET_CURRENT_STATUS: + Status = bcm_char_ioctl_get_current_status(argp, Adapter); + return Status; case IOCTL_BCM_SET_MAC_TRACING: { UINT tracing_flag; From cfd01356f95ac95801d8eb183b505dd2801dc289 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:37 -0500 Subject: [PATCH 0151/1375] staging/bcm: move IOCTL_BCM_SET_MAC_TRACING case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 40 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index da8443574643..30a00f9bcf3f 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1057,6 +1057,27 @@ static int bcm_char_ioctl_get_current_status(void __user *argp, struct bcm_mini_ } +static int bcm_char_ioctl_set_mac_tracing(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + UINT tracing_flag; + + /* copy ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) + return -EFAULT; + + if (tracing_flag) + Adapter->pTarangs->MacTracingEnabled = TRUE; + else + Adapter->pTarangs->MacTracingEnabled = false; + + return STATUS_SUCCESS; +} + + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -1210,22 +1231,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_get_current_status(argp, Adapter); return Status; - case IOCTL_BCM_SET_MAC_TRACING: { - UINT tracing_flag; - - /* copy ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&tracing_flag, IoBuffer.InputBuffer, sizeof(UINT))) - return -EFAULT; - - if (tracing_flag) - Adapter->pTarangs->MacTracingEnabled = TRUE; - else - Adapter->pTarangs->MacTracingEnabled = false; - break; - } + case IOCTL_BCM_SET_MAC_TRACING: + Status = bcm_char_ioctl_set_mac_tracing(argp, Adapter); + return Status; case IOCTL_BCM_GET_DSX_INDICATION: { ULONG ulSFId = 0; From 4d476affecd21c5e0d8387486c5eb00f56d47c4c Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:42 -0500 Subject: [PATCH 0152/1375] staging/bcm: move IOCTL_BCM_GET_DSX_INDICATION case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 46 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 30a00f9bcf3f..00c66f503799 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1077,6 +1077,29 @@ static int bcm_char_ioctl_set_mac_tracing(void __user *argp, struct bcm_mini_ada return STATUS_SUCCESS; } +static int bcm_char_ioctl_get_dsx_indication(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + ULONG ulSFId = 0; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(struct bcm_add_indication_alt)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Mismatch req: %lx needed is =0x%zx!!!", + IoBuffer.OutputLength, sizeof(struct bcm_add_indication_alt)); + return -EINVAL; + } + + if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) + return -EFAULT; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId); + get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1235,26 +1258,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_set_mac_tracing(argp, Adapter); return Status; - case IOCTL_BCM_GET_DSX_INDICATION: { - ULONG ulSFId = 0; - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.OutputLength < sizeof(struct bcm_add_indication_alt)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Mismatch req: %lx needed is =0x%zx!!!", - IoBuffer.OutputLength, sizeof(struct bcm_add_indication_alt)); - return -EINVAL; - } - - if (copy_from_user(&ulSFId, IoBuffer.InputBuffer, sizeof(ulSFId))) - return -EFAULT; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId); - get_dsx_sf_data_to_application(Adapter, ulSFId, IoBuffer.OutputBuffer); - Status = STATUS_SUCCESS; - } - break; + case IOCTL_BCM_GET_DSX_INDICATION: + Status = bcm_char_ioctl_get_dsx_indication(argp, Adapter); + return Status; case IOCTL_BCM_GET_HOST_MIBS: { PVOID temp_buff; From db9a4dc78f961a4f4a3812f5a6f7cf79d56814ed Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:47 -0500 Subject: [PATCH 0153/1375] staging/bcm: move IOCTL_BCM_GET_HOST_MIBS case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 68 +++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 00c66f503799..fb252c25f5ef 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1100,6 +1100,41 @@ static int bcm_char_ioctl_get_dsx_indication(void __user *argp, struct bcm_mini_ return STATUS_SUCCESS; } +static int bcm_char_ioctl_get_host_mibs(void __user *argp, struct bcm_mini_adapter *Adapter, struct bcm_tarang_data *pTarang) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + PVOID temp_buff; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength != sizeof(struct bcm_host_stats_mibs)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "Length Check failed %lu %zd\n", + IoBuffer.OutputLength, sizeof(struct bcm_host_stats_mibs)); + return -EINVAL; + } + + /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ + temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL); + if (!temp_buff) + return STATUS_FAILURE; + + Status = ProcessGetHostMibs(Adapter, temp_buff); + GetDroppedAppCntrlPktMibs(temp_buff, pTarang); + + if (Status != STATUS_FAILURE) { + if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(struct bcm_host_stats_mibs))) { + kfree(temp_buff); + return -EFAULT; + } + } + + kfree(temp_buff); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1262,36 +1297,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_get_dsx_indication(argp, Adapter); return Status; - case IOCTL_BCM_GET_HOST_MIBS: { - PVOID temp_buff; - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.OutputLength != sizeof(struct bcm_host_stats_mibs)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Length Check failed %lu %zd\n", - IoBuffer.OutputLength, sizeof(struct bcm_host_stats_mibs)); - return -EINVAL; - } - - /* FIXME: HOST_STATS are too big for kmalloc (122048)! */ - temp_buff = kzalloc(sizeof(struct bcm_host_stats_mibs), GFP_KERNEL); - if (!temp_buff) - return STATUS_FAILURE; - - Status = ProcessGetHostMibs(Adapter, temp_buff); - GetDroppedAppCntrlPktMibs(temp_buff, pTarang); - - if (Status != STATUS_FAILURE) - if (copy_to_user(IoBuffer.OutputBuffer, temp_buff, sizeof(struct bcm_host_stats_mibs))) { - kfree(temp_buff); - return -EFAULT; - } - - kfree(temp_buff); - break; - } + case IOCTL_BCM_GET_HOST_MIBS: + Status = bcm_char_ioctl_get_host_mibs(argp, Adapter, pTarang); + return Status; case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: if ((false == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE == Adapter->IdleMode)) { From b32384b43d12a72ffd1493c8f60803d023b96726 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:52 -0500 Subject: [PATCH 0154/1375] staging/bcm: move IOCTL_BCM_BULK_WRM case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 126 ++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 61 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index fb252c25f5ef..e67e73ae3072 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1135,6 +1135,68 @@ static int bcm_char_ioctl_get_host_mibs(void __user *argp, struct bcm_mini_adapt return Status; } +static int bcm_char_ioctl_bulk_wrm(void __user *argp, struct bcm_mini_adapter *Adapter, UINT cmd) +{ + struct bcm_bulk_wrm_buffer *pBulkBuffer; + struct bcm_ioctl_buffer IoBuffer; + UINT uiTempVar = 0; + INT Status = STATUS_FAILURE; + PCHAR pvBuffer = NULL; + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); + return -EACCES; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.InputLength < sizeof(ULONG) * 2) + return -EINVAL; + + pvBuffer = memdup_user(IoBuffer.InputBuffer, + IoBuffer.InputLength); + if (IS_ERR(pvBuffer)) + return PTR_ERR(pvBuffer); + + pBulkBuffer = (struct bcm_bulk_wrm_buffer *)pvBuffer; + + if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || + ((ULONG)pBulkBuffer->Register & 0x3)) { + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)pBulkBuffer->Register); + kfree(pvBuffer); + return -EINVAL; + } + + uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; + if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && + ((uiTempVar == EEPROM_REJECT_REG_1) || + (uiTempVar == EEPROM_REJECT_REG_2) || + (uiTempVar == EEPROM_REJECT_REG_3) || + (uiTempVar == EEPROM_REJECT_REG_4)) && + (cmd == IOCTL_BCM_REGISTER_WRITE)) { + + kfree(pvBuffer); + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); + return -EFAULT; + } + + if (pBulkBuffer->SwapEndian == false) + Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); + else + Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); + + if (Status != STATUS_SUCCESS) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); + + kfree(pvBuffer); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1311,67 +1373,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = STATUS_SUCCESS; break; - case IOCTL_BCM_BULK_WRM: { - struct bcm_bulk_wrm_buffer *pBulkBuffer; - UINT uiTempVar = 0; - PCHAR pvBuffer = NULL; - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n"); - Status = -EACCES; - break; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.InputLength < sizeof(ULONG) * 2) - return -EINVAL; - - pvBuffer = memdup_user(IoBuffer.InputBuffer, - IoBuffer.InputLength); - if (IS_ERR(pvBuffer)) - return PTR_ERR(pvBuffer); - - pBulkBuffer = (struct bcm_bulk_wrm_buffer *)pvBuffer; - - if (((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 || - ((ULONG)pBulkBuffer->Register & 0x3)) { - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n", (int)pBulkBuffer->Register); - kfree(pvBuffer); - Status = -EINVAL; - break; - } - - uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK; - if (!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE) && - ((uiTempVar == EEPROM_REJECT_REG_1) || - (uiTempVar == EEPROM_REJECT_REG_2) || - (uiTempVar == EEPROM_REJECT_REG_3) || - (uiTempVar == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) { - - kfree(pvBuffer); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n"); - Status = -EFAULT; - break; - } - - if (pBulkBuffer->SwapEndian == false) - Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); - else - Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG)); - - if (Status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); - - kfree(pvBuffer); - break; - } + case IOCTL_BCM_BULK_WRM: + Status = bcm_char_ioctl_bulk_wrm(argp, Adapter, cmd); + return Status; case IOCTL_BCM_GET_NVM_SIZE: if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) From 1c55e38104fdb9b60efb1db13f82f120b86e55eb Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:46:57 -0500 Subject: [PATCH 0155/1375] staging/bcm: move IOCTL_BCM_GET_NVM_SIZE case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index e67e73ae3072..064fc5173dc5 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1197,6 +1197,20 @@ static int bcm_char_ioctl_bulk_wrm(void __user *argp, struct bcm_mini_adapter *A return Status; } +static int bcm_char_ioctl_get_nvm_size(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) + return -EFAULT; + } + + return STATUS_SUCCESS; +} static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1378,16 +1392,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case IOCTL_BCM_GET_NVM_SIZE: - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH) { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiNVMDSDSize, sizeof(UINT))) - return -EFAULT; - } - - Status = STATUS_SUCCESS; - break; + Status = bcm_char_ioctl_get_nvm_size(argp, Adapter); + return Status; case IOCTL_BCM_CAL_INIT: { UINT uiSectorSize = 0; From 1e1ee184628a1f7e9597e58f90a187c7c1afd7d0 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:02 -0500 Subject: [PATCH 0156/1375] staging/bcm: move IOCTL_BCM_CAL_INIT case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 75 ++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 064fc5173dc5..dc0e53493e64 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1212,6 +1212,45 @@ static int bcm_char_ioctl_get_nvm_size(void __user *argp, struct bcm_mini_adapte return STATUS_SUCCESS; } +static int bcm_char_ioctl_cal_init(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + UINT uiSectorSize = 0; + INT Status = STATUS_FAILURE; + + if (Adapter->eNVMType == NVM_FLASH) { + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) + return -EFAULT; + + if ((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, + sizeof(UINT))) + return -EFAULT; + } else { + if (IsFlash2x(Adapter)) { + if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, sizeof(UINT))) + return -EFAULT; + } else { + if ((TRUE == Adapter->bShutStatus) || (TRUE == Adapter->IdleMode)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is in Idle/Shutdown Mode\n"); + return -EACCES; + } + + Adapter->uiSectorSize = uiSectorSize; + BcmUpdateSectorSize(Adapter, Adapter->uiSectorSize); + } + } + Status = STATUS_SUCCESS; + } else { + Status = STATUS_FAILURE; + } + return Status; +} + + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -1395,39 +1434,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_get_nvm_size(argp, Adapter); return Status; - case IOCTL_BCM_CAL_INIT: { - UINT uiSectorSize = 0; - if (Adapter->eNVMType == NVM_FLASH) { - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&uiSectorSize, IoBuffer.InputBuffer, sizeof(UINT))) - return -EFAULT; - - if ((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE)) { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, - sizeof(UINT))) - return -EFAULT; - } else { - if (IsFlash2x(Adapter)) { - if (copy_to_user(IoBuffer.OutputBuffer, &Adapter->uiSectorSize, sizeof(UINT))) - return -EFAULT; - } else { - if ((TRUE == Adapter->bShutStatus) || (TRUE == Adapter->IdleMode)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is in Idle/Shutdown Mode\n"); - return -EACCES; - } - - Adapter->uiSectorSize = uiSectorSize; - BcmUpdateSectorSize(Adapter, Adapter->uiSectorSize); - } - } - Status = STATUS_SUCCESS; - } else { - Status = STATUS_FAILURE; - } - } - break; + case IOCTL_BCM_CAL_INIT: + Status = bcm_char_ioctl_cal_init(argp, Adapter); + return Status; case IOCTL_BCM_SET_DEBUG: #ifdef DEBUG From 085ca029bef8e120ebf2b400ba28eef336fe6fe8 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:08 -0500 Subject: [PATCH 0157/1375] staging/bcm: move IOCTL_BCM_SET_DEBUG case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 71 +++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index dc0e53493e64..a5d5c58b5a90 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1250,6 +1250,42 @@ static int bcm_char_ioctl_cal_init(void __user *argp, struct bcm_mini_adapter *A return Status; } +static int bcm_char_ioctl_set_debug(void __user *argp, struct bcm_mini_adapter *Adapter) +{ +#ifdef DEBUG + struct bcm_ioctl_buffer IoBuffer; + struct bcm_user_debug_state sUserDebugState; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(struct bcm_user_debug_state))) + return -EFAULT; + + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", + sUserDebugState.OnOff, sUserDebugState.Type); + /* sUserDebugState.Subtype <<= 1; */ + sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; + BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); + + /* Update new 'DebugState' in the Adapter */ + Adapter->stDebugState.type |= sUserDebugState.Type; + /* Subtype: A bitmap of 32 bits for Subtype per Type. + * Valid indexes in 'subtype' array: 1,2,4,8 + * corresponding to valid Type values. Hence we can use the 'Type' field + * as the index value, ignoring the array entries 0,3,5,6,7 ! + */ + if (sUserDebugState.OnOff) + Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; + else + Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; + + BCM_SHOW_DEBUG_BITMAP(Adapter); +#endif + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1439,39 +1475,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case IOCTL_BCM_SET_DEBUG: -#ifdef DEBUG - { - struct bcm_user_debug_state sUserDebugState; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(struct bcm_user_debug_state))) - return -EFAULT; - - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", - sUserDebugState.OnOff, sUserDebugState.Type); - /* sUserDebugState.Subtype <<= 1; */ - sUserDebugState.Subtype = 1 << sUserDebugState.Subtype; - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype); - - /* Update new 'DebugState' in the Adapter */ - Adapter->stDebugState.type |= sUserDebugState.Type; - /* Subtype: A bitmap of 32 bits for Subtype per Type. - * Valid indexes in 'subtype' array: 1,2,4,8 - * corresponding to valid Type values. Hence we can use the 'Type' field - * as the index value, ignoring the array entries 0,3,5,6,7 ! - */ - if (sUserDebugState.OnOff) - Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype; - else - Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype; - - BCM_SHOW_DEBUG_BITMAP(Adapter); - } -#endif - break; + Status = bcm_char_ioctl_set_debug(argp, Adapter); + return Status; case IOCTL_BCM_NVM_READ: case IOCTL_BCM_NVM_WRITE: { From 5be531c22a9fa2b8f988462fa3950fa2fe33eacd Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:13 -0500 Subject: [PATCH 0158/1375] staging/bcm: move IOCTL_BCM_NVM_[READ|WRITE] cases out to their own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 290 +++++++++++++++++----------------- 1 file changed, 149 insertions(+), 141 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index a5d5c58b5a90..3564018f56d7 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1286,6 +1286,152 @@ static int bcm_char_ioctl_set_debug(void __user *argp, struct bcm_mini_adapter * return STATUS_SUCCESS; } +static int bcm_char_ioctl_nvm_rw(void __user *argp, struct bcm_mini_adapter *Adapter, UINT cmd) +{ + struct bcm_nvm_readwrite stNVMReadWrite; + struct timeval tv0, tv1; + struct bcm_ioctl_buffer IoBuffer; + PUCHAR pReadData = NULL; + ULONG ulDSDMagicNumInUsrBuff = 0; + INT Status = STATUS_FAILURE; + + memset(&tv0, 0, sizeof(struct timeval)); + memset(&tv1, 0, sizeof(struct timeval)); + if ((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); + return -EFAULT; + } + + if (IsFlash2x(Adapter)) { + if ((Adapter->eActiveDSD != DSD0) && + (Adapter->eActiveDSD != DSD1) && + (Adapter->eActiveDSD != DSD2)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No DSD is active..hence NVM Command is blocked"); + return STATUS_FAILURE; + } + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (copy_from_user(&stNVMReadWrite, + (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, + sizeof(struct bcm_nvm_readwrite))) + return -EFAULT; + + /* + * Deny the access if the offset crosses the cal area limit. + */ + if (stNVMReadWrite.uiNumBytes > Adapter->uiNVMDSDSize) + return STATUS_FAILURE; + + if (stNVMReadWrite.uiOffset > Adapter->uiNVMDSDSize - stNVMReadWrite.uiNumBytes) { + /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); */ + return STATUS_FAILURE; + } + + pReadData = memdup_user(stNVMReadWrite.pBuffer, + stNVMReadWrite.uiNumBytes); + if (IS_ERR(pReadData)) + return PTR_ERR(pReadData); + + do_gettimeofday(&tv0); + if (IOCTL_BCM_NVM_READ == cmd) { + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; + } + + Status = BeceemNVMRead(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { + kfree(pReadData); + return Status; + } + + if (copy_to_user(stNVMReadWrite.pBuffer, pReadData, stNVMReadWrite.uiNumBytes)) { + kfree(pReadData); + return -EFAULT; + } + } else { + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; + } + + Adapter->bHeaderChangeAllowed = TRUE; + if (IsFlash2x(Adapter)) { + /* + * New Requirement:- + * DSD section updation will be allowed in two case:- + * 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull + * 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is + * corrupted then user space program first modify the DSD header with valid DSD sig so + * that this as well as further write may be worthwhile. + * + * This restriction has been put assuming that if DSD sig is corrupted, DSD + * data won't be considered valid. + */ + + Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); + if (Status != STATUS_SUCCESS) { + if (((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize) || + (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return Status; + } + + ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); + if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return Status; + } + } + } + + Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); + if (IsFlash2x(Adapter)) + BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); + + Adapter->bHeaderChangeAllowed = false; + + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { + kfree(pReadData); + return Status; + } + } + + do_gettimeofday(&tv1); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n", (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000); + + kfree(pReadData); + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1479,147 +1625,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case IOCTL_BCM_NVM_READ: - case IOCTL_BCM_NVM_WRITE: { - struct bcm_nvm_readwrite stNVMReadWrite; - PUCHAR pReadData = NULL; - ULONG ulDSDMagicNumInUsrBuff = 0; - struct timeval tv0, tv1; - memset(&tv0, 0, sizeof(struct timeval)); - memset(&tv1, 0, sizeof(struct timeval)); - if ((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); - return -EFAULT; - } - - if (IsFlash2x(Adapter)) { - if ((Adapter->eActiveDSD != DSD0) && - (Adapter->eActiveDSD != DSD1) && - (Adapter->eActiveDSD != DSD2)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No DSD is active..hence NVM Command is blocked"); - return STATUS_FAILURE; - } - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&stNVMReadWrite, - (IOCTL_BCM_NVM_READ == cmd) ? IoBuffer.OutputBuffer : IoBuffer.InputBuffer, - sizeof(struct bcm_nvm_readwrite))) - return -EFAULT; - - /* - * Deny the access if the offset crosses the cal area limit. - */ - if (stNVMReadWrite.uiNumBytes > Adapter->uiNVMDSDSize) - return STATUS_FAILURE; - - if (stNVMReadWrite.uiOffset > Adapter->uiNVMDSDSize - stNVMReadWrite.uiNumBytes) { - /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); */ - return STATUS_FAILURE; - } - - pReadData = memdup_user(stNVMReadWrite.pBuffer, - stNVMReadWrite.uiNumBytes); - if (IS_ERR(pReadData)) - return PTR_ERR(pReadData); - - do_gettimeofday(&tv0); - if (IOCTL_BCM_NVM_READ == cmd) { - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return -EACCES; - } - - Status = BeceemNVMRead(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); - up(&Adapter->NVMRdmWrmLock); - - if (Status != STATUS_SUCCESS) { - kfree(pReadData); - return Status; - } - - if (copy_to_user(stNVMReadWrite.pBuffer, pReadData, stNVMReadWrite.uiNumBytes)) { - kfree(pReadData); - return -EFAULT; - } - } else { - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return -EACCES; - } - - Adapter->bHeaderChangeAllowed = TRUE; - if (IsFlash2x(Adapter)) { - /* - * New Requirement:- - * DSD section updation will be allowed in two case:- - * 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull - * 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is - * corrupted then user space program first modify the DSD header with valid DSD sig so - * that this as well as further write may be worthwhile. - * - * This restriction has been put assuming that if DSD sig is corrupted, DSD - * data won't be considered valid. - */ - - Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); - if (Status != STATUS_SUCCESS) { - if (((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize) || - (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return Status; - } - - ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); - if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "DSD Sig is present neither in Flash nor User provided Input.."); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return Status; - } - } - } - - Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify); - if (IsFlash2x(Adapter)) - BcmFlash2xWriteSig(Adapter, Adapter->eActiveDSD); - - Adapter->bHeaderChangeAllowed = false; - - up(&Adapter->NVMRdmWrmLock); - - if (Status != STATUS_SUCCESS) { - kfree(pReadData); - return Status; - } - } - - do_gettimeofday(&tv1); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n", (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000); - - kfree(pReadData); - return STATUS_SUCCESS; - } + case IOCTL_BCM_NVM_WRITE: + Status = bcm_char_ioctl_nvm_rw(argp, Adapter, cmd); + return Status; case IOCTL_BCM_FLASH2X_SECTION_READ: { struct bcm_flash2x_readwrite sFlash2xRead = {0}; From b4571fc2067b2568c5c05b063e7488ba30476670 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:18 -0500 Subject: [PATCH 0159/1375] staging/bcm: move IOCTL_BCM_FLASH2X_SECTION_READ case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 187 ++++++++++++++++++---------------- 1 file changed, 97 insertions(+), 90 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 3564018f56d7..b0b14e31a394 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1432,6 +1432,100 @@ static int bcm_char_ioctl_nvm_rw(void __user *argp, struct bcm_mini_adapter *Ada return STATUS_SUCCESS; } +static int bcm_char_ioctl_flash2x_section_read(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_readwrite sFlash2xRead = {0}; + struct bcm_ioctl_buffer IoBuffer; + PUCHAR pReadBuff = NULL; + UINT NOB = 0; + UINT BuffSize = 0; + UINT ReadBytes = 0; + UINT ReadOffset = 0; + INT Status = STATUS_FAILURE; + void __user *OutPutBuff; + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + /* Reading FLASH 2.x READ structure */ + if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) + return -EFAULT; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xRead.Section); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%x", sFlash2xRead.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xRead.numOfBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xRead.bVerify); + + /* This was internal to driver for raw read. now it has ben exposed to user space app. */ + if (validateFlash2xReadWrite(Adapter, &sFlash2xRead) == false) + return STATUS_FAILURE; + + NOB = sFlash2xRead.numOfBytes; + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB; + + ReadOffset = sFlash2xRead.offset; + OutPutBuff = IoBuffer.OutputBuffer; + pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); + + if (pReadBuff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); + return -ENOMEM; + } + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return -EACCES; + } + + while (NOB) { + if (NOB > Adapter->uiSectorSize) + ReadBytes = Adapter->uiSectorSize; + else + ReadBytes = NOB; + + /* Reading the data from Flash 2.x */ + Status = BcmFlash2xBulkRead(Adapter, (PUINT)pReadBuff, sFlash2xRead.Section, ReadOffset, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Flash 2x read err with Status :%d", Status); + break; + } + + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); + + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy to use failed with status :%d", Status); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return -EFAULT; + } + NOB = NOB - ReadBytes; + if (NOB) { + ReadOffset = ReadOffset + ReadBytes; + OutPutBuff = OutPutBuff + ReadBytes; + } + } + + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1629,96 +1723,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_nvm_rw(argp, Adapter, cmd); return Status; - case IOCTL_BCM_FLASH2X_SECTION_READ: { - struct bcm_flash2x_readwrite sFlash2xRead = {0}; - PUCHAR pReadBuff = NULL; - UINT NOB = 0; - UINT BuffSize = 0; - UINT ReadBytes = 0; - UINT ReadOffset = 0; - void __user *OutPutBuff; - - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&sFlash2xRead, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) - return -EFAULT; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xRead.Section); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%x", sFlash2xRead.offset); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xRead.numOfBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xRead.bVerify); - - /* This was internal to driver for raw read. now it has ben exposed to user space app. */ - if (validateFlash2xReadWrite(Adapter, &sFlash2xRead) == false) - return STATUS_FAILURE; - - NOB = sFlash2xRead.numOfBytes; - if (NOB > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB; - - ReadOffset = sFlash2xRead.offset; - OutPutBuff = IoBuffer.OutputBuffer; - pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL); - - if (pReadBuff == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); - return -ENOMEM; - } - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EACCES; - } - - while (NOB) { - if (NOB > Adapter->uiSectorSize) - ReadBytes = Adapter->uiSectorSize; - else - ReadBytes = NOB; - - /* Reading the data from Flash 2.x */ - Status = BcmFlash2xBulkRead(Adapter, (PUINT)pReadBuff, sFlash2xRead.Section, ReadOffset, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Flash 2x read err with Status :%d", Status); - break; - } - - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); - - Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy to use failed with status :%d", Status); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EFAULT; - } - NOB = NOB - ReadBytes; - if (NOB) { - ReadOffset = ReadOffset + ReadBytes; - OutPutBuff = OutPutBuff + ReadBytes; - } - } - - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - } - break; + case IOCTL_BCM_FLASH2X_SECTION_READ: + Status = bcm_char_ioctl_flash2x_section_read(argp, Adapter); + return Status; case IOCTL_BCM_FLASH2X_SECTION_WRITE: { struct bcm_flash2x_readwrite sFlash2xWrite = {0}; From 174b3b46bdceb7f4663ef7227dd9ede394732e58 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:23 -0500 Subject: [PATCH 0160/1375] staging/bcm: move IOCTL_BCM_FLASH2X_SECTION_WRITE case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 223 ++++++++++++++++++---------------- 1 file changed, 115 insertions(+), 108 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index b0b14e31a394..77e96e040f34 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1526,6 +1526,118 @@ static int bcm_char_ioctl_flash2x_section_read(void __user *argp, struct bcm_min return Status; } +static int bcm_char_ioctl_flash2x_section_write(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_readwrite sFlash2xWrite = {0}; + struct bcm_ioctl_buffer IoBuffer; + PUCHAR pWriteBuff; + void __user *InputAddr; + UINT NOB = 0; + UINT BuffSize = 0; + UINT WriteOffset = 0; + UINT WriteBytes = 0; + INT Status = STATUS_FAILURE; + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + /* First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite */ + Adapter->bAllDSDWriteAllow = false; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + /* Reading FLASH 2.x READ structure */ + if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) + return -EFAULT; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xWrite.Section); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%d", sFlash2xWrite.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xWrite.numOfBytes); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xWrite.bVerify); + + if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && (sFlash2xWrite.Section != VSA2)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Only VSA write is allowed"); + return -EINVAL; + } + + if (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == false) + return STATUS_FAILURE; + + InputAddr = sFlash2xWrite.pDataBuff; + WriteOffset = sFlash2xWrite.offset; + NOB = sFlash2xWrite.numOfBytes; + + if (NOB > Adapter->uiSectorSize) + BuffSize = Adapter->uiSectorSize; + else + BuffSize = NOB; + + pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); + + if (pWriteBuff == NULL) + return -ENOMEM; + + /* extracting the remainder of the given offset. */ + WriteBytes = Adapter->uiSectorSize; + if (WriteOffset % Adapter->uiSectorSize) + WriteBytes = Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); + + if (NOB < WriteBytes) + WriteBytes = NOB; + + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return -EACCES; + } + + BcmFlash2xCorruptSig(Adapter, sFlash2xWrite.Section); + do { + Status = copy_from_user(pWriteBuff, InputAddr, WriteBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to user failed with status :%d", Status); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return -EFAULT; + } + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pWriteBuff, WriteBytes); + + /* Writing the data from Flash 2.x */ + Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, sFlash2xWrite.Section, WriteOffset, WriteBytes, sFlash2xWrite.bVerify); + + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); + break; + } + + NOB = NOB - WriteBytes; + if (NOB) { + WriteOffset = WriteOffset + WriteBytes; + InputAddr = InputAddr + WriteBytes; + if (NOB > Adapter->uiSectorSize) + WriteBytes = Adapter->uiSectorSize; + else + WriteBytes = NOB; + } + } while (NOB > 0); + + BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); + up(&Adapter->NVMRdmWrmLock); + kfree(pWriteBuff); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1727,114 +1839,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_flash2x_section_read(argp, Adapter); return Status; - case IOCTL_BCM_FLASH2X_SECTION_WRITE: { - struct bcm_flash2x_readwrite sFlash2xWrite = {0}; - PUCHAR pWriteBuff; - void __user *InputAddr; - UINT NOB = 0; - UINT BuffSize = 0; - UINT WriteOffset = 0; - UINT WriteBytes = 0; - - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } - - /* First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite */ - Adapter->bAllDSDWriteAllow = false; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&sFlash2xWrite, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_readwrite))) - return -EFAULT; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.Section :%x", sFlash2xWrite.Section); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.offset :%d", sFlash2xWrite.offset); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.numOfBytes :%x", sFlash2xWrite.numOfBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\nsFlash2xRead.bVerify :%x\n", sFlash2xWrite.bVerify); - - if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) && (sFlash2xWrite.Section != VSA2)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Only VSA write is allowed"); - return -EINVAL; - } - - if (validateFlash2xReadWrite(Adapter, &sFlash2xWrite) == false) - return STATUS_FAILURE; - - InputAddr = sFlash2xWrite.pDataBuff; - WriteOffset = sFlash2xWrite.offset; - NOB = sFlash2xWrite.numOfBytes; - - if (NOB > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = NOB; - - pWriteBuff = kmalloc(BuffSize, GFP_KERNEL); - - if (pWriteBuff == NULL) - return -ENOMEM; - - /* extracting the remainder of the given offset. */ - WriteBytes = Adapter->uiSectorSize; - if (WriteOffset % Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); - - if (NOB < WriteBytes) - WriteBytes = NOB; - - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - return -EACCES; - } - - BcmFlash2xCorruptSig(Adapter, sFlash2xWrite.Section); - do { - Status = copy_from_user(pWriteBuff, InputAddr, WriteBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to user failed with status :%d", Status); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - return -EFAULT; - } - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pWriteBuff, WriteBytes); - - /* Writing the data from Flash 2.x */ - Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, sFlash2xWrite.Section, WriteOffset, WriteBytes, sFlash2xWrite.bVerify); - - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); - break; - } - - NOB = NOB - WriteBytes; - if (NOB) { - WriteOffset = WriteOffset + WriteBytes; - InputAddr = InputAddr + WriteBytes; - if (NOB > Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize; - else - WriteBytes = NOB; - } - } while (NOB > 0); - - BcmFlash2xWriteSig(Adapter, sFlash2xWrite.Section); - up(&Adapter->NVMRdmWrmLock); - kfree(pWriteBuff); - } - break; + case IOCTL_BCM_FLASH2X_SECTION_WRITE: + Status = bcm_char_ioctl_flash2x_section_write(argp, Adapter); + return Status; case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: { struct bcm_flash2x_bitmap *psFlash2xBitMap; From 338a5c4a36d360865163fd6c5b32d9ae474bd61d Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:28 -0500 Subject: [PATCH 0161/1375] staging/bcm: move IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 86 +++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 77e96e040f34..6732e6311db0 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1638,6 +1638,50 @@ static int bcm_char_ioctl_flash2x_section_write(void __user *argp, struct bcm_mi return Status; } +static int bcm_char_ioctl_flash2x_section_bitmap(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_bitmap *psFlash2xBitMap; + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + +BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength != sizeof(struct bcm_flash2x_bitmap)) + return -EINVAL; + + psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), GFP_KERNEL); + if (psFlash2xBitMap == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory is not available"); + return -ENOMEM; + } + + /* Reading the Flash Sectio Bit map */ + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(psFlash2xBitMap); + return -EACCES; + } + + BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); + up(&Adapter->NVMRdmWrmLock); + if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(struct bcm_flash2x_bitmap))) { + kfree(psFlash2xBitMap); + return -EFAULT; + } + + kfree(psFlash2xBitMap); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1843,45 +1887,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_flash2x_section_write(argp, Adapter); return Status; - case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: { - struct bcm_flash2x_bitmap *psFlash2xBitMap; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.OutputLength != sizeof(struct bcm_flash2x_bitmap)) - return -EINVAL; - - psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), GFP_KERNEL); - if (psFlash2xBitMap == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory is not available"); - return -ENOMEM; - } - - /* Reading the Flash Sectio Bit map */ - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(psFlash2xBitMap); - return -EACCES; - } - - BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap); - up(&Adapter->NVMRdmWrmLock); - if (copy_to_user(IoBuffer.OutputBuffer, psFlash2xBitMap, sizeof(struct bcm_flash2x_bitmap))) { - kfree(psFlash2xBitMap); - return -EFAULT; - } - - kfree(psFlash2xBitMap); - } - break; + case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: + Status = bcm_char_ioctl_flash2x_section_bitmap(argp, Adapter); + return Status; case IOCTL_BCM_SET_ACTIVE_SECTION: { enum bcm_flash2x_section_val eFlash2xSectionVal = 0; From 9e0d6e1a0d9c6edba6dc27978b921180a1bef509 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:33 -0500 Subject: [PATCH 0162/1375] staging/bcm: move IOCTL_BCM_SET_ACTIVE_SECTION case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 87 +++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 6732e6311db0..010dd2a56df0 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1682,6 +1682,51 @@ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_ return Status; } +static int bcm_char_ioctl_set_active_section(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + enum bcm_flash2x_section_val eFlash2xSectionVal = 0; + INT Status = STATUS_FAILURE; + struct bcm_ioctl_buffer IoBuffer; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + return -EFAULT; + } + + Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); + return -EFAULT; + } + + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } + + Status = BcmSetActiveSection(Adapter, eFlash2xSectionVal); + if (Status) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Failed to make it's priority Highest. Status %d", Status); + + up(&Adapter->NVMRdmWrmLock); + + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1891,45 +1936,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_flash2x_section_bitmap(argp, Adapter); return Status; - case IOCTL_BCM_SET_ACTIVE_SECTION: { - enum bcm_flash2x_section_val eFlash2xSectionVal = 0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called"); - - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } - - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - - Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return -EFAULT; - } - - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } - - Status = BcmSetActiveSection(Adapter, eFlash2xSectionVal); - if (Status) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Failed to make it's priority Highest. Status %d", Status); - - up(&Adapter->NVMRdmWrmLock); - } - break; + case IOCTL_BCM_SET_ACTIVE_SECTION: + Status = bcm_char_ioctl_set_active_section(argp, Adapter); + return Status; case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: { /* Right Now we are taking care of only DSD */ From 56b682a5ac237c02cf7c11748e4f285fe0c8b0cb Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:38 -0500 Subject: [PATCH 0163/1375] staging/bcm: formatting cleaning for IOCTL_BCM_IDENTIFY_ACTIVE_SECTION Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 010dd2a56df0..a4a68a9bbd5f 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1940,13 +1940,12 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_set_active_section(argp, Adapter); return Status; - case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: { + case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: /* Right Now we are taking care of only DSD */ Adapter->bAllDSDWriteAllow = false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); Status = STATUS_SUCCESS; - } - break; + break; case IOCTL_BCM_COPY_SECTION: { struct bcm_flash2x_copy_section sCopySectStrut = {0}; From 3e2aea599222a5f345fc425084fb17668f5d88e5 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:43 -0500 Subject: [PATCH 0164/1375] staging/bcm: move IOCTL_BCM_COPY_SECTION case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 153 ++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 73 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index a4a68a9bbd5f..7cf793b2746a 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1727,6 +1727,83 @@ static int bcm_char_ioctl_set_active_section(void __user *argp, struct bcm_mini_ return Status; } +static int bcm_char_ioctl_copy_section(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_flash2x_copy_section sCopySectStrut = {0}; + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_SUCCESS; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called"); + + Adapter->bAllDSDWriteAllow = false; + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); + return -EFAULT; + } + + Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_copy_section)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); + return -EFAULT; + } + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes); + + if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source Section<%x> does not exist in Flash ", sCopySectStrut.SrcSection); + return -EINVAL; + } + + if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == false) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destinatio Section<%x> does not exist in Flash ", sCopySectStrut.DstSection); + return -EINVAL; + } + + if (sCopySectStrut.SrcSection == sCopySectStrut.DstSection) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source and Destination section should be different"); + return -EINVAL; + } + + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } + + if (sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2) { + if (IsNonCDLessDevice(Adapter)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is Non-CDLess hence won't have ISO !!"); + Status = -EINVAL; + } else if (sCopySectStrut.numOfBytes == 0) { + Status = BcmCopyISO(Adapter, sCopySectStrut); + } else { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Partial Copy of ISO section is not Allowed.."); + Status = STATUS_FAILURE; + } + up(&Adapter->NVMRdmWrmLock); + return Status; + } + + Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, + sCopySectStrut.DstSection, sCopySectStrut.offset, sCopySectStrut.numOfBytes); + up(&Adapter->NVMRdmWrmLock); + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -1947,79 +2024,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = STATUS_SUCCESS; break; - case IOCTL_BCM_COPY_SECTION: { - struct bcm_flash2x_copy_section sCopySectStrut = {0}; - Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called"); - - Adapter->bAllDSDWriteAllow = false; - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } - - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); - return -EFAULT; - } - - Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, sizeof(struct bcm_flash2x_copy_section)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status); - return -EFAULT; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes); - - if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source Section<%x> does not exist in Flash ", sCopySectStrut.SrcSection); - return -EINVAL; - } - - if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destinatio Section<%x> does not exist in Flash ", sCopySectStrut.DstSection); - return -EINVAL; - } - - if (sCopySectStrut.SrcSection == sCopySectStrut.DstSection) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source and Destination section should be different"); - return -EINVAL; - } - - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } - - if (sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2) { - if (IsNonCDLessDevice(Adapter)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device is Non-CDLess hence won't have ISO !!"); - Status = -EINVAL; - } else if (sCopySectStrut.numOfBytes == 0) { - Status = BcmCopyISO(Adapter, sCopySectStrut); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Partial Copy of ISO section is not Allowed.."); - Status = STATUS_FAILURE; - } - up(&Adapter->NVMRdmWrmLock); - return Status; - } - - Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection, - sCopySectStrut.DstSection, sCopySectStrut.offset, sCopySectStrut.numOfBytes); - up(&Adapter->NVMRdmWrmLock); - } - break; + case IOCTL_BCM_COPY_SECTION: + Status = bcm_char_ioctl_copy_section(argp, Adapter); + return Status; case IOCTL_BCM_GET_FLASH_CS_INFO: { Status = STATUS_SUCCESS; From 3aae97fb491bf17d0ef0b39b55207fa3f199cc89 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:48 -0500 Subject: [PATCH 0165/1375] staging/bcm: move IOCTL_BCM_GET_FLASH_CS_INFO case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 68 +++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 7cf793b2746a..95cad1cfdce3 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1804,6 +1804,40 @@ static int bcm_char_ioctl_copy_section(void __user *argp, struct bcm_mini_adapte return Status; } +static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_SUCCESS; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); + + Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + return -EFAULT; + } + + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Connected device does not have flash"); + return -EINVAL; + } + + if (IsFlash2x(Adapter) == TRUE) { + if (IoBuffer.OutputLength < sizeof(struct bcm_flash2x_cs_info)) + return -EINVAL; + + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(struct bcm_flash2x_cs_info))) + return -EFAULT; + } else { + if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info)) + return -EINVAL; + + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(struct bcm_flash_cs_info))) + return -EFAULT; + } + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -2028,37 +2062,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_copy_section(argp, Adapter); return Status; - case IOCTL_BCM_GET_FLASH_CS_INFO: { - Status = STATUS_SUCCESS; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); - - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - - if (Adapter->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Connected device does not have flash"); - Status = -EINVAL; - break; - } - - if (IsFlash2x(Adapter) == TRUE) { - if (IoBuffer.OutputLength < sizeof(struct bcm_flash2x_cs_info)) - return -EINVAL; - - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(struct bcm_flash2x_cs_info))) - return -EFAULT; - } else { - if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info)) - return -EINVAL; - - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(struct bcm_flash_cs_info))) - return -EFAULT; - } - } - break; + case IOCTL_BCM_GET_FLASH_CS_INFO: + Status = bcm_char_ioctl_get_flash_cs_info(argp, Adapter); + return Status; case IOCTL_BCM_SELECT_DSD: { UINT SectOfset = 0; From 3c06b7a174bd4e8ca1db9614a9d5be49db2dc868 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:53 -0500 Subject: [PATCH 0166/1375] staging/bcm: move IOCTL_BCM_SELECT_DSD case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 93 +++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 95cad1cfdce3..046e67ff2e35 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1838,6 +1838,53 @@ static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, struct bcm_mini_a return Status; } +static int bcm_char_ioctl_select_dsd(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + UINT SectOfset = 0; + enum bcm_flash2x_section_val eFlash2xSectionVal; + + eFlash2xSectionVal = NO_SECTION_VAL; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SELECT_DSD Called"); + + if (IsFlash2x(Adapter) != TRUE) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); + return -EINVAL; + } + + Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); + return -EFAULT; + } + Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); + return -EFAULT; + } + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read Section :%d", eFlash2xSectionVal); + if ((eFlash2xSectionVal != DSD0) && + (eFlash2xSectionVal != DSD1) && + (eFlash2xSectionVal != DSD2)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Passed section<%x> is not DSD section", eFlash2xSectionVal); + return STATUS_FAILURE; + } + + SectOfset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); + if (SectOfset == INVALID_OFFSET) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section val <%d> does not exist in Flash 2.x", eFlash2xSectionVal); + return -EINVAL; + } + + Adapter->bAllDSDWriteAllow = TRUE; + Adapter->ulFlashCalStart = SectOfset; + Adapter->eActiveDSD = eFlash2xSectionVal; + + return STATUS_SUCCESS; +} static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -2066,49 +2113,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_get_flash_cs_info(argp, Adapter); return Status; - case IOCTL_BCM_SELECT_DSD: { - UINT SectOfset = 0; - enum bcm_flash2x_section_val eFlash2xSectionVal; - eFlash2xSectionVal = NO_SECTION_VAL; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SELECT_DSD Called"); - - if (IsFlash2x(Adapter) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Does not have 2.x map"); - return -EINVAL; - } - - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); - return -EFAULT; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read Section :%d", eFlash2xSectionVal); - if ((eFlash2xSectionVal != DSD0) && - (eFlash2xSectionVal != DSD1) && - (eFlash2xSectionVal != DSD2)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Passed section<%x> is not DSD section", eFlash2xSectionVal); - return STATUS_FAILURE; - } - - SectOfset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); - if (SectOfset == INVALID_OFFSET) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section val <%d> does not exist in Flash 2.x", eFlash2xSectionVal); - return -EINVAL; - } - - Adapter->bAllDSDWriteAllow = TRUE; - Adapter->ulFlashCalStart = SectOfset; - Adapter->eActiveDSD = eFlash2xSectionVal; - } - Status = STATUS_SUCCESS; - break; + case IOCTL_BCM_SELECT_DSD: + Status = bcm_char_ioctl_select_dsd(argp, Adapter); + return Status; case IOCTL_BCM_NVM_RAW_READ: { struct bcm_nvm_readwrite stNVMRead; From b3e5804e48dfad205ef45f03e30afb8a31256566 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:47:59 -0500 Subject: [PATCH 0167/1375] staging/bcm: move IOCTL_BCM_NVM_RAW_READ case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 181 ++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 87 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 046e67ff2e35..0dc1c88c4576 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1886,6 +1886,97 @@ static int bcm_char_ioctl_select_dsd(void __user *argp, struct bcm_mini_adapter return STATUS_SUCCESS; } +static int bcm_char_ioctl_nvm_raw_read(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_nvm_readwrite stNVMRead; + struct bcm_ioctl_buffer IoBuffer; + INT NOB; + INT BuffSize; + INT ReadOffset = 0; + UINT ReadBytes = 0; + PUCHAR pReadBuff; + void __user *OutPutBuff; + INT Status = STATUS_FAILURE; + + if (Adapter->eNVMType != NVM_FLASH) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "NVM TYPE is not Flash"); + return -EINVAL; + } + + /* Copy Ioctl Buffer structure */ + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); + return -EFAULT; + } + + if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, sizeof(struct bcm_nvm_readwrite))) + return -EFAULT; + + NOB = stNVMRead.uiNumBytes; + /* In Raw-Read max Buff size : 64MB */ + + if (NOB > DEFAULT_BUFF_SIZE) + BuffSize = DEFAULT_BUFF_SIZE; + else + BuffSize = NOB; + + ReadOffset = stNVMRead.uiOffset; + OutPutBuff = stNVMRead.pBuffer; + + pReadBuff = kzalloc(BuffSize , GFP_KERNEL); + if (pReadBuff == NULL) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); + return -ENOMEM; + } + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || + (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + kfree(pReadBuff); + up(&Adapter->NVMRdmWrmLock); + return -EACCES; + } + + Adapter->bFlashRawRead = TRUE; + + while (NOB) { + if (NOB > DEFAULT_BUFF_SIZE) + ReadBytes = DEFAULT_BUFF_SIZE; + else + ReadBytes = NOB; + + /* Reading the data from Flash 2.x */ + Status = BeceemNVMRead(Adapter, (PUINT)pReadBuff, ReadOffset, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); + break; + } + + BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); + + Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to use failed with status :%d", Status); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return -EFAULT; + } + NOB = NOB - ReadBytes; + if (NOB) { + ReadOffset = ReadOffset + ReadBytes; + OutPutBuff = OutPutBuff + ReadBytes; + } + } + Adapter->bFlashRawRead = false; + up(&Adapter->NVMRdmWrmLock); + kfree(pReadBuff); + return Status; +} + + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { struct bcm_tarang_data *pTarang = filp->private_data; @@ -2117,93 +2208,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_select_dsd(argp, Adapter); return Status; - case IOCTL_BCM_NVM_RAW_READ: { - struct bcm_nvm_readwrite stNVMRead; - INT NOB; - INT BuffSize; - INT ReadOffset = 0; - UINT ReadBytes = 0; - PUCHAR pReadBuff; - void __user *OutPutBuff; - - if (Adapter->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "NVM TYPE is not Flash"); - return -EINVAL; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n"); - return -EFAULT; - } - - if (copy_from_user(&stNVMRead, IoBuffer.OutputBuffer, sizeof(struct bcm_nvm_readwrite))) - return -EFAULT; - - NOB = stNVMRead.uiNumBytes; - /* In Raw-Read max Buff size : 64MB */ - - if (NOB > DEFAULT_BUFF_SIZE) - BuffSize = DEFAULT_BUFF_SIZE; - else - BuffSize = NOB; - - ReadOffset = stNVMRead.uiOffset; - OutPutBuff = stNVMRead.pBuffer; - - pReadBuff = kzalloc(BuffSize , GFP_KERNEL); - if (pReadBuff == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for Flash 2.x Read Structure"); - Status = -ENOMEM; - break; - } - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); - kfree(pReadBuff); - up(&Adapter->NVMRdmWrmLock); - return -EACCES; - } - - Adapter->bFlashRawRead = TRUE; - - while (NOB) { - if (NOB > DEFAULT_BUFF_SIZE) - ReadBytes = DEFAULT_BUFF_SIZE; - else - ReadBytes = NOB; - - /* Reading the data from Flash 2.x */ - Status = BeceemNVMRead(Adapter, (PUINT)pReadBuff, ReadOffset, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash 2x read err with Status :%d", Status); - break; - } - - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, pReadBuff, ReadBytes); - - Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy to use failed with status :%d", Status); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - return -EFAULT; - } - NOB = NOB - ReadBytes; - if (NOB) { - ReadOffset = ReadOffset + ReadBytes; - OutPutBuff = OutPutBuff + ReadBytes; - } - } - Adapter->bFlashRawRead = false; - up(&Adapter->NVMRdmWrmLock); - kfree(pReadBuff); - break; - } + case IOCTL_BCM_NVM_RAW_READ: + Status = bcm_char_ioctl_nvm_raw_read(argp, Adapter); + return Status; case IOCTL_BCM_CNTRLMSG_MASK: { ULONG RxCntrlMsgBitMask = 0; From 8f7e14eee717487086c66ae17fb9936e834c4469 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:48:04 -0500 Subject: [PATCH 0168/1375] staging/bcm: move IOCTL_BCM_CNTRLMSG_MASK case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 54 +++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 0dc1c88c4576..2cfdbeeff14a 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1976,6 +1976,33 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, struct bcm_mini_adapte return Status; } +static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp, struct bcm_mini_adapter *Adapter, struct bcm_tarang_data *pTarang) +{ + struct bcm_ioctl_buffer IoBuffer; + INT Status = STATUS_FAILURE; + ULONG RxCntrlMsgBitMask = 0; + + /* Copy Ioctl Buffer structure */ + Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of Ioctl buffer is failed from user space"); + return -EFAULT; + } + + if (IoBuffer.InputLength != sizeof(unsigned long)) + return -EINVAL; + + Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength); + if (Status) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of control bit mask failed from user space"); + return -EFAULT; + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); + pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask; + + return Status; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -2212,30 +2239,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_nvm_raw_read(argp, Adapter); return Status; - case IOCTL_BCM_CNTRLMSG_MASK: { - ULONG RxCntrlMsgBitMask = 0; - - /* Copy Ioctl Buffer structure */ - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of Ioctl buffer is failed from user space"); - return -EFAULT; - } - - if (IoBuffer.InputLength != sizeof(unsigned long)) { - Status = -EINVAL; - break; - } - - Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of control bit mask failed from user space"); - return -EFAULT; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask); - pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask; - } - break; + case IOCTL_BCM_CNTRLMSG_MASK: + Status = bcm_char_ioctl_cntrlmsg_mask(argp, Adapter, pTarang); + return Status; case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: { struct bcm_driver_info DevInfo; From fe59cefb6971ded0f130bbdd3dfeb1fcc9446c31 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:48:09 -0500 Subject: [PATCH 0169/1375] staging/bcm: move IOCTL_BCM_GET_DEVICE_DRIVER_INFO case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 51 ++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 2cfdbeeff14a..74360ee45c2b 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -2003,6 +2003,32 @@ static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp, struct bcm_mini_adapt return Status; } +static int bcm_char_ioctl_get_device_driver_info(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_driver_info DevInfo; + struct bcm_ioctl_buffer IoBuffer; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); + + memset(&DevInfo, 0, sizeof(DevInfo)); + DevInfo.MaxRDMBufferSize = BUFFER_4K; + DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; + DevInfo.u32RxAlignmentCorrection = 0; + DevInfo.u32NVMType = Adapter->eNVMType; + DevInfo.u32InterfaceType = BCM_USB; + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(DevInfo)) + return -EINVAL; + + if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) + return -EFAULT; + + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -2243,28 +2269,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_cntrlmsg_mask(argp, Adapter, pTarang); return Status; - case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: { - struct bcm_driver_info DevInfo; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); - - memset(&DevInfo, 0, sizeof(DevInfo)); - DevInfo.MaxRDMBufferSize = BUFFER_4K; - DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; - DevInfo.u32RxAlignmentCorrection = 0; - DevInfo.u32NVMType = Adapter->eNVMType; - DevInfo.u32InterfaceType = BCM_USB; - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.OutputLength < sizeof(DevInfo)) - return -EINVAL; - - if (copy_to_user(IoBuffer.OutputBuffer, &DevInfo, sizeof(DevInfo))) - return -EFAULT; - } - break; + case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: + Status = bcm_char_ioctl_get_device_driver_info(argp, Adapter); + return Status; case IOCTL_BCM_TIME_SINCE_NET_ENTRY: { struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; From 84f7a542f9e0191b6f7ab87881a050889576a5c4 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 13 Feb 2014 14:48:14 -0500 Subject: [PATCH 0170/1375] staging/bcm: move IOCTL_BCM_TIME_SINCE_NET_ENTRY case out to its own function. bcm_char_ioctl is one of the longest non-generated functions in the kernel, at 1906 lines. Splitting it up into multiple functions should simplify this a lot. Signed-off-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 42 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 74360ee45c2b..fdebc3bba0b5 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -2029,6 +2029,27 @@ static int bcm_char_ioctl_get_device_driver_info(void __user *argp, struct bcm_m return STATUS_SUCCESS; } +static int bcm_char_ioctl_time_since_net_entry(void __user *argp, struct bcm_mini_adapter *Adapter) +{ + struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; + struct bcm_ioctl_buffer IoBuffer; + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); + + if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) + return -EFAULT; + + if (IoBuffer.OutputLength < sizeof(struct bcm_time_elapsed)) + return -EINVAL; + + stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; + + if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(struct bcm_time_elapsed))) + return -EFAULT; + + return STATUS_SUCCESS; +} + static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) { @@ -2036,7 +2057,6 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) void __user *argp = (void __user *)arg; struct bcm_mini_adapter *Adapter = pTarang->Adapter; INT Status = STATUS_FAILURE; - struct bcm_ioctl_buffer IoBuffer; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", @@ -2273,23 +2293,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) Status = bcm_char_ioctl_get_device_driver_info(argp, Adapter); return Status; - case IOCTL_BCM_TIME_SINCE_NET_ENTRY: { - struct bcm_time_elapsed stTimeElapsedSinceNetEntry = {0}; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); - - if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (IoBuffer.OutputLength < sizeof(struct bcm_time_elapsed)) - return -EINVAL; - - stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = get_seconds() - Adapter->liTimeSinceLastNetEntry; - - if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, sizeof(struct bcm_time_elapsed))) - return -EFAULT; - } - break; + case IOCTL_BCM_TIME_SINCE_NET_ENTRY: + Status = bcm_char_ioctl_time_since_net_entry(argp, Adapter); + return Status; case IOCTL_CLOSE_NOTIFICATION: BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_CLOSE_NOTIFICATION"); From 52cf6acfb0a81267848701ad385ec735c0bd61b2 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 15 Feb 2014 01:11:17 +0900 Subject: [PATCH 0171/1375] staging:lustre: Fix typo in comment and printk within lustre/obdclass This patch fixed spelling typo within lustre/lustre/obdclass. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/cl_io.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 6 +++--- drivers/staging/lustre/lustre/obdclass/llog_lvfs.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog_osd.c | 6 +++--- drivers/staging/lustre/lustre/obdclass/local_storage.c | 2 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/md_attrs.c | 6 +++--- drivers/staging/lustre/lustre/obdclass/obd_config.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/obdo.c | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index e048500edd60..3bebc78e7673 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -942,7 +942,7 @@ int cl_io_cancel(const struct lu_env *env, struct cl_io *io, struct cl_page *page; int result = 0; - CERROR("Canceling ongoing page trasmission\n"); + CERROR("Canceling ongoing page transmission\n"); cl_page_list_for_each(page, queue) { int rc; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 1a926036724b..0fc256f59e92 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -508,7 +508,7 @@ EXPORT_SYMBOL(cl_site_stats_print); * about journal_info. Currently following fields in task_struct are identified * can be used for this purpose: * - cl_env: for liblustre. - * - tux_info: ony on RedHat kernel. + * - tux_info: only on RedHat kernel. * - ... * \note As long as we use task_struct to store cl_env, we assume that once * called into Lustre, we'll never call into the other part of the kernel diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index d9f750d42c80..d27f0411d355 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -1625,7 +1625,7 @@ static int obd_zombie_impexp_check(void *arg) } /** - * Add export to the obd_zombe thread and notify it. + * Add export to the obd_zombie thread and notify it. */ static void obd_zombie_export_add(struct obd_export *exp) { spin_lock(&exp->exp_obd->obd_dev_lock); @@ -1641,7 +1641,7 @@ static void obd_zombie_export_add(struct obd_export *exp) { } /** - * Add import to the obd_zombe thread and notify it. + * Add import to the obd_zombie thread and notify it. */ static void obd_zombie_import_add(struct obd_import *imp) { LASSERT(imp->imp_sec == NULL); @@ -1661,7 +1661,7 @@ static void obd_zombie_import_add(struct obd_import *imp) { static void obd_zombie_impexp_notify(void) { /* - * Make sure obd_zomebie_impexp_thread get this notification. + * Make sure obd_zombie_impexp_thread get this notification. * It is possible this signal only get by obd_zombie_barrier, and * barrier gulps this notification and sleeps away and hangs ensues */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c index 5385d8e658cf..d86bb8c60354 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c @@ -376,7 +376,7 @@ static void llog_skip_over(__u64 *off, int curr, int goal) /* sets: * - cur_offset to the furthest point read in the log file - * - cur_idx to the log index preceeding cur_offset + * - cur_idx to the log index preceding cur_offset * returns -EIO/-EINVAL on error */ static int llog_lvfs_next_block(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 654c8e189653..682279de8bea 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -514,7 +514,7 @@ static void llog_skip_over(__u64 *off, int curr, int goal) /* sets: * - cur_offset to the furthest point read in the log file - * - cur_idx to the log index preceeding cur_offset + * - cur_idx to the log index preceding cur_offset * returns -EIO/-EINVAL on error */ static int llog_osd_next_block(const struct lu_env *env, @@ -1073,7 +1073,7 @@ static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd, LASSERT(ctxt); /* initialize data allowing to generate new fids, - * literally we need a sequece */ + * literally we need a sequence */ lgi->lgi_fid.f_seq = FID_SEQ_LLOG; lgi->lgi_fid.f_oid = 1; lgi->lgi_fid.f_ver = 0; @@ -1280,7 +1280,7 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, lgi->lgi_buf.lb_len = size; rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th); if (rc) - CDEBUG(D_INODE, "error writeing CATALOGS: rc = %d\n", rc); + CDEBUG(D_INODE, "error writing CATALOGS: rc = %d\n", rc); out_trans: dt_trans_stop(env, d, th); out: diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c b/drivers/staging/lustre/lustre/obdclass/local_storage.c index e79e4beb3628..e76f7d044231 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.c +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c @@ -737,7 +737,7 @@ int lastid_compat_check(const struct lu_env *env, struct dt_device *dev, * All dynamic fids will be generated with the same sequence and incremented * OIDs * - * Returned local_oid_storage is in-memory representaion of OID storage + * Returned local_oid_storage is in-memory representation of OID storage */ int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev, const struct lu_fid *first_fid, diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 9887d8fffb6e..492964a38e7c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -2100,7 +2100,7 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o, EXPORT_SYMBOL(lu_object_assign_fid); /** - * allocates object with 0 (non-assiged) fid + * allocates object with 0 (non-assigned) fid * XXX: temporary solution to be able to assign fid in ->do_create() * till we have fully-functional OST fids */ diff --git a/drivers/staging/lustre/lustre/obdclass/md_attrs.c b/drivers/staging/lustre/lustre/obdclass/md_attrs.c index f7187829e276..f080cceb384c 100644 --- a/drivers/staging/lustre/lustre/obdclass/md_attrs.c +++ b/drivers/staging/lustre/lustre/obdclass/md_attrs.c @@ -60,7 +60,7 @@ EXPORT_SYMBOL(lustre_lma_init); */ void lustre_lma_swab(struct lustre_mdt_attrs *lma) { - /* Use LUSTRE_MSG_MAGIC to detect local endianess. */ + /* Use LUSTRE_MSG_MAGIC to detect local endianness. */ if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC)) { __swab32s(&lma->lma_compat); __swab32s(&lma->lma_incompat); @@ -77,7 +77,7 @@ EXPORT_SYMBOL(lustre_lma_swab); */ void lustre_som_swab(struct som_attrs *attrs) { - /* Use LUSTRE_MSG_MAGIC to detect local endianess. */ + /* Use LUSTRE_MSG_MAGIC to detect local endianness. */ if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC)) { __swab32s(&attrs->som_compat); __swab32s(&attrs->som_incompat); @@ -135,7 +135,7 @@ EXPORT_SYMBOL(lustre_buf2som); */ void lustre_hsm_swab(struct hsm_attrs *attrs) { - /* Use LUSTRE_MSG_MAGIC to detect local endianess. */ + /* Use LUSTRE_MSG_MAGIC to detect local endianness. */ if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC)) { __swab32s(&attrs->hsm_compat); __swab32s(&attrs->hsm_flags); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 27f56c0ab441..2cdfa21638e2 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -592,7 +592,7 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) } EXPORT_SYMBOL(class_detach); -/** Start shutting down the obd. There may be in-progess ops when +/** Start shutting down the obd. There may be in-progress ops when * this is called. We tell them to start shutting down with a call * to class_disconnect_exports(). */ @@ -655,7 +655,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) /* The three references that should be remaining are the * obd_self_export and the attach and setup references. */ if (atomic_read(&obd->obd_refcount) > 3) { - /* refcounf - 3 might be the number of real exports + /* refcount - 3 might be the number of real exports (excluding self export). But class_incref is called by other things as well, so don't count on it. */ CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n", diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index a69a630b596e..6f8ba54e9667 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -501,7 +501,7 @@ static int lustre_stop_mgc(struct super_block *sb) } /* The MGC has no recoverable data in any case. - * force shotdown set in umount_begin */ + * force shutdown set in umount_begin */ obd->obd_no_recov = 1; if (obd->u.cli.cl_mgc_mgsexp) { @@ -754,7 +754,7 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) } EXPORT_SYMBOL(server_name2index); -/*************** mount common betweeen server and client ***************/ +/*************** mount common between server and client ***************/ /* Common umount */ int lustre_common_put_super(struct super_block *sb) diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index e9cd6db43eeb..3b1b28afd6b1 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -191,7 +191,7 @@ int obdo_cmp_md(struct obdo *dst, struct obdo *src, obd_flag compare) } if ( compare & OBD_MD_FLGENER ) res = (res || (dst->o_parent_oid != src->o_parent_oid)); - /* XXX Don't know if thses should be included here - wasn't previously + /* XXX Don't know if these should be included here - wasn't previously if ( compare & OBD_MD_FLINLINE ) res = (res || memcmp(dst->o_inline, src->o_inline)); */ From 6bc2b856bb7c49f238914d965c0b1057ec78226e Mon Sep 17 00:00:00 2001 From: Weijie Yang Date: Fri, 14 Feb 2014 14:03:56 +0800 Subject: [PATCH 0172/1375] staging: android: lowmemorykiller: set TIF_MEMDIE before send kill sig Set TIF_MEMDIE tsk_thread flag before send kill signal to the selected thread. This is to fit a usual code sequence and avoid potential race issue. Signed-off-by: Weijie Yang Acked-by: David Rientjes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/lowmemorykiller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index 6f094b37f1f1..4bcf00a87270 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -159,8 +159,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) selected->pid, selected->comm, selected_oom_score_adj, selected_tasksize); lowmem_deathpending_timeout = jiffies + HZ; - send_sig(SIGKILL, selected, 0); set_tsk_thread_flag(selected, TIF_MEMDIE); + send_sig(SIGKILL, selected, 0); rem += selected_tasksize; } From b0377d4bd438d00310005190a46920cb0279106f Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Thu, 13 Feb 2014 19:02:26 -0600 Subject: [PATCH 0173/1375] Staging: comedi: clean up conditional statement in addi_apci_3xxx.c In this conditional statement, if (chan < 16), but the instruction passed in data[0] is INSN_CONFIG_DIO_QUERY, the function does not return early, but the else-branch does not get executed either. As a result, mask would be used uninitialized in the next line. We want comedi_dio_insn_config() to use a chan_mask based on the chanspec for the INSN_CONFIG_DIO_QUERY instruction, so mask should be initialized to 0. Then, if instead the instruction is INSN_CONFIG_DIO_{INPUT,OUTPUT}, we return an error if (chan < 16) as these are invalid instructions for ports 0 and 1, or update the mask otherwise, so all the io_bits are modified for port 2. This ensures that mask is always initialized by the time it is used. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index ceadf8eff47f..1f3b668f7f1f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -680,7 +680,7 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; + unsigned int mask = 0; int ret; /* @@ -688,12 +688,13 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev, * Port 1 (channels 8-15) are always outputs * Port 2 (channels 16-23) are programmable i/o */ - if (chan < 16) { - if (data[0] != INSN_CONFIG_DIO_QUERY) + if (data[0] != INSN_CONFIG_DIO_QUERY) { + /* ignore all other instructions for ports 0 and 1 */ + if (chan < 16) return -EINVAL; - } else { - /* changing any channel in port 2 changes the entire port */ - mask = 0xff0000; + else + /* changing any channel in port 2 changes the entire port */ + mask = 0xff0000; } ret = comedi_dio_insn_config(dev, s, insn, data, mask); From 9f999462c38c1229aa49c51b4e5fec18c6037c01 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 13 Feb 2014 13:00:18 +0100 Subject: [PATCH 0174/1375] staging: r8188eu: Remove dead code There are a few lines in this driver that depend on a macro CONFIG_BT_COEXIST. But there's no Kconfig symbol of that name nor is there a preprocessor define for that string. So remove these lines. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_debug.h | 10 ---------- drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 4 ---- 2 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h index 1cdc07dcb87c..ae05141f5ddf 100644 --- a/drivers/staging/rtl8188eu/include/rtw_debug.h +++ b/drivers/staging/rtl8188eu/include/rtw_debug.h @@ -263,14 +263,4 @@ int proc_get_rssi_disp(char *page, char **start, int proc_set_rssi_disp(struct file *file, const char __user *buffer, unsigned long count, void *data); -#ifdef CONFIG_BT_COEXIST -int proc_get_btcoex_dbg(char *page, char **start, - off_t offset, int count, - int *eof, void *data); - -int proc_set_btcoex_dbg(struct file *file, const char *buffer, - signed long count, void *data); - -#endif /* CONFIG_BT_COEXIST */ - #endif /* __RTW_DEBUG_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index 4a0e9ff3d479..9a42859d612b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -206,10 +206,6 @@ struct pwrctrl_priv { u8 bInternalAutoSuspend; u8 bInSuspend; -#ifdef CONFIG_BT_COEXIST - u8 bAutoResume; - u8 autopm_cnt; -#endif u8 bSupportRemoteWakeup; struct timer_list pwr_state_check_timer; int pwr_state_check_interval; From c3eaaf8b5b01cf076525e23d26269027a8cfe8a6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 12 Feb 2014 17:10:28 -0600 Subject: [PATCH 0175/1375] staging: rtl8821ae: Fix potential infinite loop Smatch reports the following: drivers/staging/rtl8821ae/rtl8821ae/hw.c:153 _rtl8821ae_set_fw_clock_on() info: ignoring unreachable code. Upon investigation, the code in this region has the capability of creating an infinite loop. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.c b/drivers/staging/rtl8821ae/rtl8821ae/hw.c index 5ed7a114c56b..e8344be92344 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.c @@ -147,6 +147,7 @@ static void _rtl8821ae_set_fw_clock_on(struct ieee80211_hw *hw, } else { rtlhal->bfw_clk_change_in_progress = false; spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + break; } } From cf867c3930b9b685364ec4fda20ff8a5a1e06ad6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 12 Feb 2014 16:14:35 -0600 Subject: [PATCH 0176/1375] staging: r8188eu: Fix more Smatch warnings and errors After updating Smatch, the following new errors and warnings are reported: drivers/staging/rtl8188eu/core/rtw_recv.c:368 recvframe_chkmic() warn: variable dereferenced before check 'psecuritypriv' (see line 364) drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:2642 rtw_wps_start() warn: variable dereferenced before check 'pdata' (see line 2636) drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:4461 rtw_dbg_port() error: we previously assumed 'pregpriv' could be null (see line 4453) drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:4473 rtw_dbg_port() error: we previously assumed 'pregpriv' could be null (see line 4469) Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 7 +++---- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 4de98b622426..fccea1e27006 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -361,16 +361,15 @@ static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvfra /* calculate mic code */ if (stainfo != NULL) { if (IS_MCAST(prxattrib->ra)) { - mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; - - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); - if (!psecuritypriv) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); goto exit; } + mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); } else { mickey = &stainfo->dot11tkiprxmickey.skey[0]; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 7de813986ff0..36910072cf87 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -2633,13 +2633,13 @@ static int rtw_wps_start(struct net_device *dev, struct iw_point *pdata = &wrqu->data; u32 u32wps_start = 0; - ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); - if (ret) { + if ((padapter->bDriverStopped) || (pdata == NULL)) { ret = -EINVAL; goto exit; } - if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); + if (ret) { ret = -EINVAL; goto exit; } @@ -4450,11 +4450,9 @@ static int rtw_dbg_port(struct net_device *dev, struct registry_priv *pregpriv = &padapter->registrypriv; /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ - if (pregpriv && - (extra_arg == 0 || - extra_arg == 1 || - extra_arg == 2 || - extra_arg == 3)) { + if (!pregpriv) + break; + if (extra_arg >= 0 && extra_arg <= 3) { pregpriv->rx_stbc = extra_arg; DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc); } else { @@ -4466,7 +4464,9 @@ static int rtw_dbg_port(struct net_device *dev, { struct registry_priv *pregpriv = &padapter->registrypriv; /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ - if (pregpriv && extra_arg >= 0 && extra_arg < 3) { + if (!pregpriv) + break; + if (extra_arg >= 0 && extra_arg < 3) { pregpriv->ampdu_enable = extra_arg; DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable); } else { From bacb6de62cce0af3be40248c89f980b604b8a54f Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Wed, 12 Feb 2014 11:54:32 -0800 Subject: [PATCH 0177/1375] staging: Additional item for rtl8188eu TODO list The rtw_recv_indicatepkt() function in the file named drivers/staging/rtl8188eu/os_dep/recv_linux.c has this strange code: rcu_read_lock(); rcu_dereference(padapter->pnetdev->rx_handler_data); rcu_read_unlock(); This code has no effect. Normally, you would assign the result of rcu_dereference() to some variable, but it is not clear from the code what variable that would be. Therefore, this patch applies to the TODO file instead of the code itself. Signed-off-by: Paul E. McKenney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/TODO | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/rtl8188eu/TODO b/drivers/staging/rtl8188eu/TODO index f7f389c40e71..b574b235b340 100644 --- a/drivers/staging/rtl8188eu/TODO +++ b/drivers/staging/rtl8188eu/TODO @@ -9,6 +9,11 @@ TODO: - merge Realtek's bugfixes and new features into the driver - switch to use LIB80211 - switch to use MAC80211 +- figure out what to do with this code in rtw_recv_indicatepkt(): + rcu_read_lock(); + rcu_dereference(padapter->pnetdev->rx_handler_data); + rcu_read_unlock(); + Perhaps delete it, perhaps assign to some local variable. Please send any patches to Greg Kroah-Hartman , and Larry Finger . From 0ca3e288ddd5b9a42728cdb984a68d86d45dd09a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Feb 2014 19:18:26 +0000 Subject: [PATCH 0178/1375] staging: vt6656: device_set_multi: covert mc_filter to u64 Convert mc_filter to u64, preform netdev_for_each_mc_addr mask filtering. In MACvWriteMultiAddr endian correct mc_filter and write the entire multicast once. Reported-by: Joe Perches Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 16 +++++----------- drivers/staging/vt6656/mac.h | 2 +- drivers/staging/vt6656/main_usb.c | 18 ++++++++---------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 54414ed27191..3ce19ddbc569 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -47,25 +47,19 @@ static int msglevel =MSG_LEVEL_INFO; * * Parameters: * In: - * uByteidx - Index of Mask - * byData - Mask Value to write + * mc_filter (mac filter) * Out: * none * * Return Value: none * */ -void MACvWriteMultiAddr(struct vnt_private *pDevice, u32 uByteIdx, u8 byData) +void MACvWriteMultiAddr(struct vnt_private *pDevice, u64 mc_filter) { - u8 byData1; + __le64 le_mc = cpu_to_le64(mc_filter); - byData1 = byData; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - (u16) (MAC_REG_MAR0 + uByteIdx), - MESSAGE_REQUEST_MACREG, - 1, - &byData1); + CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, + MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc); } /* diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 0db1be5b01c8..4053e431ef99 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -403,7 +403,7 @@ #define MAC_REVISION_A0 0x00 #define MAC_REVISION_A1 0x01 -void MACvWriteMultiAddr(struct vnt_private *, u32, u8); +void MACvWriteMultiAddr(struct vnt_private *, u64); void MACbShutdown(struct vnt_private *); void MACvSetBBType(struct vnt_private *, u8); void MACvDisableKeyEntry(struct vnt_private *, u32); diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 6bd27cf43af7..ffcce0cdde07 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -1353,8 +1353,7 @@ static void device_set_multi(struct net_device *dev) struct vnt_private *pDevice = netdev_priv(dev); struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct netdev_hw_addr *ha; - u32 mc_filter[2]; - int ii; + u64 mc_filter = 0; u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 byTmpMode = 0; int rc; @@ -1388,15 +1387,14 @@ static void device_set_multi(struct net_device *dev) pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); } else { - memset(mc_filter, 0, sizeof(mc_filter)); netdev_for_each_mc_addr(ha, dev) { - int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; - mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31)); - } - for (ii = 0; ii < 4; ii++) { - MACvWriteMultiAddr(pDevice, ii, *((u8 *)&mc_filter[0] + ii)); - MACvWriteMultiAddr(pDevice, ii+ 4, *((u8 *)&mc_filter[1] + ii)); - } + int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + + mc_filter |= 1ULL << (bit_nr & 0x3f); + } + + MACvWriteMultiAddr(pDevice, mc_filter); + pDevice->byRxMode &= ~(RCR_UNICAST); pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); } From 295508cc3f25e97ab69bc96d2cd06f2ee1c6bff3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Feb 2014 19:20:48 +0000 Subject: [PATCH 0179/1375] staging: vt6656: device_set_multi: set filter off with MACvWriteMultiAddr set u64 mc_filter to ~0x0 multi cast filter off and write MAC_REG_MAR0 using MACvWriteMultiAddr to replace pbyData. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ffcce0cdde07..a48736b0c185 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -1354,7 +1354,6 @@ static void device_set_multi(struct net_device *dev) struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct netdev_hw_addr *ha; u64 mc_filter = 0; - u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 byTmpMode = 0; int rc; @@ -1377,13 +1376,9 @@ static void device_set_multi(struct net_device *dev) } else if ((netdev_mc_count(dev) > pDevice->multicast_limit) || (dev->flags & IFF_ALLMULTI)) { - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_MAR0, - MESSAGE_REQUEST_MACREG, - 8, - pbyData - ); + mc_filter = ~0x0; + MACvWriteMultiAddr(pDevice, mc_filter); + pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); } else { From e40068a63c20ba58ced1eb86642205ef849284a7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Feb 2014 19:22:37 +0000 Subject: [PATCH 0180/1375] staging: vt6656: camel case and clean up devie_set_multi White space clean up Camel case changes pDevice -> priv pMgmt -> mgmt byTmpMode -> tmp Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 87 ++++++++++++++++--------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index a48736b0c185..664781c8c10f 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -1350,62 +1350,63 @@ static int Read_config_file(struct vnt_private *pDevice) static void device_set_multi(struct net_device *dev) { - struct vnt_private *pDevice = netdev_priv(dev); - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_private *priv = netdev_priv(dev); + struct vnt_manager *mgmt = &priv->vnt_mgmt; struct netdev_hw_addr *ha; u64 mc_filter = 0; - u8 byTmpMode = 0; + u8 tmp = 0; int rc; - spin_lock_irq(&pDevice->lock); - rc = CONTROLnsRequestIn(pDevice, - MESSAGE_TYPE_READ, - MAC_REG_RCR, - MESSAGE_REQUEST_MACREG, - 1, - &byTmpMode - ); - if (rc == 0) pDevice->byRxMode = byTmpMode; + spin_lock_irq(&priv->lock); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->byRxMode); + rc = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, + MAC_REG_RCR, MESSAGE_REQUEST_MACREG, 1, &tmp); + if (rc == 0) + priv->byRxMode = tmp; - if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */ - DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name); - /* unconditionally log net taps */ - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST); - } - else if ((netdev_mc_count(dev) > pDevice->multicast_limit) || - (dev->flags & IFF_ALLMULTI)) { - mc_filter = ~0x0; - MACvWriteMultiAddr(pDevice, mc_filter); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "priv->byRxMode in= %x\n", + priv->byRxMode); - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - } - else { - netdev_for_each_mc_addr(ha, dev) { - int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */ + DBG_PRT(MSG_LEVEL_ERR, KERN_NOTICE + "%s: Promiscuous mode enabled.\n", dev->name); + /* unconditionally log net taps */ + priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST); + } else if ((netdev_mc_count(dev) > priv->multicast_limit) || + (dev->flags & IFF_ALLMULTI)) { + mc_filter = ~0x0; + MACvWriteMultiAddr(priv, mc_filter); - mc_filter |= 1ULL << (bit_nr & 0x3f); + priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); + } else { + netdev_for_each_mc_addr(ha, dev) { + int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + + mc_filter |= 1ULL << (bit_nr & 0x3f); + } + + MACvWriteMultiAddr(priv, mc_filter); + + priv->byRxMode &= ~(RCR_UNICAST); + priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); } - MACvWriteMultiAddr(pDevice, mc_filter); + if (mgmt->eConfigMode == WMAC_CONFIG_AP) { + /* + * If AP mode, don't enable RCR_UNICAST since HW only compares + * addr1 with local MAC + */ + priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); + priv->byRxMode &= ~(RCR_UNICAST); + } - pDevice->byRxMode &= ~(RCR_UNICAST); - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - } + ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + MAC_REG_RCR, priv->byRxMode); - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - /* - * If AP mode, don't enable RCR_UNICAST since HW only compares - * addr1 with local MAC - */ - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - pDevice->byRxMode &= ~(RCR_UNICAST); - } - ControlvWriteByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, pDevice->byRxMode); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode out= %x\n", pDevice->byRxMode); - spin_unlock_irq(&pDevice->lock); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "priv->byRxMode out= %x\n", priv->byRxMode); + spin_unlock_irq(&priv->lock); } static struct net_device_stats *device_get_stats(struct net_device *dev) From 05c9bc1f360838623572d07452631e2228ed98bf Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 12 Feb 2014 11:27:45 -0600 Subject: [PATCH 0181/1375] staging: r8188eu: Fix Smatch warnings Smatch reports the following: core/rtw_ieee80211.c:489 rtw_get_wpa_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:491 rtw_get_wpa_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:493 rtw_get_wpa_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:495 rtw_get_wpa_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:497 rtw_get_wpa_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:505 rtw_get_wpa2_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:507 rtw_get_wpa2_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:509 rtw_get_wpa2_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:511 rtw_get_wpa2_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:513 rtw_get_wpa2_cipher_suite() warn: add some parenthesis here? core/rtw_ieee80211.c:534 rtw_parse_wpa_ie() warn: add some parenthesis here? core/rtw_ieee80211.c:579 rtw_parse_wpa_ie() warn: add some parenthesis here? core/rtw_ieee80211.c:649 rtw_parse_wpa2_ie() warn: add some parenthesis here? core/rtw_ieee80211.c:803 rtw_get_wps_attr() warn: add some parenthesis here? core/rtw_ieee80211.c:1213 rtw_get_p2p_ie() warn: add some parenthesis here? core/rtw_ieee80211.c:1248 rtw_get_p2p_attr() warn: add some parenthesis here? core/rtw_mlme.c:258 _rtw_find_network() warn: add some parenthesis here? core/rtw_mlme.c:1581 rtw_check_join_candidate() warn: this array is probably non-NULL. 'pmlmepriv->assoc_ssid.Ssid' core/rtw_mlme.c:1843 SecIsInPMKIDList() warn: add some parenthesis here? core/rtw_mlme_ext.c:4189 on_action_public_vendor() warn: add some parenthesis here? core/rtw_recv.c:1157 validate_recv_mgnt_frame() warn: add some parenthesis here? core/rtw_xmit.c:671 xmitframe_addmic() warn: add some parenthesis here? hal/rtl8188e_mp.c:206 Hal_MPT_CCKTxPowerAdjustbyIndex() error: buffer overflow 'CCKSwingTable_Ch1_Ch13' 33 <= 255 hal/rtl8188e_mp.c:215 Hal_MPT_CCKTxPowerAdjustbyIndex() error: buffer overflow 'CCKSwingTable_Ch14' 33 <= 255 Not listed here is one remaining buffer overflow message that I believe to be an error in Smatch. These warnings were reported by Dan Carpenter. Reported-by: Dan Carpenter Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_ieee80211.c | 32 +++++++++---------- drivers/staging/rtl8188eu/core/rtw_mlme.c | 6 ++-- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 3 +- drivers/staging/rtl8188eu/core/rtw_xmit.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188e_mp.c | 2 ++ 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index d779c805b8a8..4076c66833a4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -486,15 +486,15 @@ unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) int rtw_get_wpa_cipher_suite(u8 *s) { - if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN)) return WPA_CIPHER_NONE; - if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN)) return WPA_CIPHER_WEP40; - if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN)) return WPA_CIPHER_TKIP; - if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN)) return WPA_CIPHER_CCMP; - if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN)) return WPA_CIPHER_WEP104; return 0; @@ -502,15 +502,15 @@ int rtw_get_wpa_cipher_suite(u8 *s) int rtw_get_wpa2_cipher_suite(u8 *s) { - if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN)) return WPA_CIPHER_NONE; - if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN)) return WPA_CIPHER_WEP40; - if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN)) return WPA_CIPHER_TKIP; - if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN)) return WPA_CIPHER_CCMP; - if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN)) return WPA_CIPHER_WEP104; return 0; @@ -531,7 +531,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || - (!memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != true)) + (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) return _FAIL; pos = wpa_ie; @@ -576,7 +576,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4) == 1) { + if (!memcmp(pos, SUITE_1X, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); *is_8021x = 1; } @@ -646,7 +646,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4) == 1) { + if (!memcmp(pos, SUITE_1X, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); *is_8021x = 1; } @@ -800,7 +800,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at *len_attr = 0; if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || - (!memcmp(wps_ie + 2, wps_oui , 4) != true)) + (memcmp(wps_ie + 2, wps_oui , 4))) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ @@ -1210,7 +1210,7 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) dump_stack(); return NULL; } - if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&in_ie[cnt+2], p2p_oui, 4) == true)) { + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&in_ie[cnt+2], p2p_oui, 4))) { p2p_ie_ptr = in_ie + cnt; if (p2p_ie != NULL) @@ -1245,7 +1245,7 @@ u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_att *len_attr = 0; if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || - (!memcmp(p2p_ie + 2, p2p_oui , 4) != true)) + (memcmp(p2p_ie + 2, p2p_oui , 4))) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 260da41cfd46..a934bd97219d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -255,7 +255,7 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) while (plist != phead) { pnetwork = container_of(plist, struct wlan_network , list); - if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) + if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) break; plist = plist->next; } @@ -1578,7 +1578,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv } /* check ssid, if needed */ - if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { + if (pmlmepriv->assoc_ssid.SsidLength) { if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength || !memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false) goto exit; @@ -1840,7 +1840,7 @@ static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) do { if ((psecuritypriv->PMKIDList[i].bUsed) && - (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN) == true)) { + (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) { break; } else { i++; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b84610f8f58f..301cda51e4a9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -4186,7 +4186,7 @@ static unsigned int on_action_public_vendor(union recv_frame *precv_frame) u8 *pframe = precv_frame->u.hdr.rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); - if (!memcmp(frame_body + 2, P2P_OUI, 4) == true) + if (!memcmp(frame_body + 2, P2P_OUI, 4)) ret = on_action_public_p2p(precv_frame); return ret; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index fccea1e27006..794785eb54e1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -1153,7 +1153,8 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBEREQ) { psta->sta_stats.rx_probereq_pkts++; } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBERSP) { - if (!memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN) == true) + if (!memcmp(padapter->eeprompriv.mac_addr, + GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN)) psta->sta_stats.rx_probersp_pkts++; else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) || is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 48d57be0856c..b0e9798da75a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -667,7 +667,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr /* start to calculate the mic code */ rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { - if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16) == true) { + if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) { /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ /* msleep(10); */ return _FAIL; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c b/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c index cd2027b01df4..cc71784b8d73 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c @@ -201,6 +201,8 @@ void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven) else CCK_index = CCK_index_old + 1; + if (CCK_index > 32) + CCK_index = 32; /* Adjust CCK according to gain index */ if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) { rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch1_Ch13[CCK_index][0]); From 52cb15c873e12b70f3eb01b7d770fbf6f246156a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 12 Feb 2014 23:10:16 +0530 Subject: [PATCH 0182/1375] staging: rtl8188eu: remove unused header files Remove h2clbk.h and nic_spec.h header files. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/h2clbk.h | 35 ---------------- drivers/staging/rtl8188eu/include/nic_spec.h | 44 -------------------- 2 files changed, 79 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/h2clbk.h delete mode 100644 drivers/staging/rtl8188eu/include/nic_spec.h diff --git a/drivers/staging/rtl8188eu/include/h2clbk.h b/drivers/staging/rtl8188eu/include/h2clbk.h deleted file mode 100644 index e595030ac8a3..000000000000 --- a/drivers/staging/rtl8188eu/include/h2clbk.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - -#define _H2CLBK_H_ - - -#include -#include - - -void _lbk_cmd(struct adapter *adapter); - -void _lbk_rsp(struct adapter *adapter); - -void _lbk_evt(IN struct adapter *adapter); - -void h2c_event_callback(unsigned char *dev, unsigned char *pbuf); diff --git a/drivers/staging/rtl8188eu/include/nic_spec.h b/drivers/staging/rtl8188eu/include/nic_spec.h deleted file mode 100644 index d42244788ca9..000000000000 --- a/drivers/staging/rtl8188eu/include/nic_spec.h +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - -#ifndef __NIC_SPEC_H__ -#define __NIC_SPEC_H__ - -#define RTL8711_MCTRL_ (0x20000) -#define RTL8711_UART_ (0x30000) -#define RTL8711_TIMER_ (0x40000) -#define RTL8711_FINT_ (0x50000) -#define RTL8711_HINT_ (0x50000) -#define RTL8711_GPIO_ (0x60000) -#define RTL8711_WLANCTRL_ (0x200000) -#define RTL8711_WLANFF_ (0xe00000) -#define RTL8711_HCICTRL_ (0x600000) -#define RTL8711_SYSCFG_ (0x620000) -#define RTL8711_SYSCTRL_ (0x620000) -#define RTL8711_MCCTRL_ (0x020000) - - -#include - -#include - - -#endif /* __RTL8711_SPEC_H__ */ From 7a01d05e86fd0501cd2be147b3e20ee56a082651 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Sun, 9 Feb 2014 19:47:58 +0100 Subject: [PATCH 0183/1375] staging: tidspbridge: Remove OMAP_PM_SRF The symbol is an orphan, get rid of it. Cc: Paul Bolle Cc: Omar Ramirez Luna Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/tidspbridge/Kconfig b/drivers/staging/tidspbridge/Kconfig index 1b6d581c438b..b5e74e9de6bd 100644 --- a/drivers/staging/tidspbridge/Kconfig +++ b/drivers/staging/tidspbridge/Kconfig @@ -17,7 +17,7 @@ menuconfig TIDSPBRIDGE config TIDSPBRIDGE_DVFS bool "Enable Bridge Dynamic Voltage and Frequency Scaling (DVFS)" - depends on TIDSPBRIDGE && OMAP_PM_SRF && CPU_FREQ + depends on TIDSPBRIDGE && CPU_FREQ help DVFS allows DSP Bridge to initiate the operating point change to scale the chip voltage and frequency in order to match the From 00e0d3c3d73f0f99aa6024d42a27f7257f7327dd Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Fri, 14 Feb 2014 09:26:07 -0800 Subject: [PATCH 0184/1375] staging: fpgaboot: fix coccinelle warnings drivers/staging/gs_fpgaboot/gs_fpgaboot.c:305:1-3: WARNING: PTR_RET can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: coccinelle/api/ptr_ret.cocci CC: Insop Song Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index fee2f6140cae..31a6741f4d3e 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -302,10 +302,7 @@ static int init_driver(void) { firmware_pdev = platform_device_register_simple("fpgaboot", -1, NULL, 0); - if (IS_ERR(firmware_pdev)) - return PTR_ERR(firmware_pdev); - - return 0; + return PTR_ERR_OR_ZERO(firmware_pdev); } static void finish_driver(void) From c39e9c87eed0d7013760230525033c19f284c3b2 Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Fri, 14 Feb 2014 09:26:16 -0800 Subject: [PATCH 0185/1375] staging: fpgaboot: fix coccinelle warnings drivers/staging/gs_fpgaboot/gs_fpgaboot.c:191:2-3: Unneeded semicolon Removes unneeded semicolon. Generated by: coccinelle/misc/semicolon.cocci CC: Insop Song Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index 31a6741f4d3e..89bc84d833e6 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -188,7 +188,7 @@ static int gs_read_image(struct fpgaimage *fimage) default: pr_err("unsupported fpga image format\n"); return -1; - }; + } gs_print_header(fimage); From 2228c5391ba646bb647872bdec6964bbe1599f26 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 12 Feb 2014 19:21:38 +0800 Subject: [PATCH 0186/1375] staging/lustre/libcfs: remove user space code from kernel_user_comm.c Cc: Andreas Dilger Cc: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/libcfs/kernel_user_comm.c | 102 ------------------ 1 file changed, 102 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index 7b2c31599327..b6ddc998f750 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -44,106 +44,6 @@ #include -#ifdef LUSTRE_UTILS -/* This is the userspace side. */ - -/** Start the userspace side of a KUC pipe. - * @param link Private descriptor for pipe/socket. - * @param groups KUC broadcast group to listen to - * (can be null for unicast to this pid) - */ -int libcfs_ukuc_start(lustre_kernelcomm *link, int group) -{ - int pfd[2]; - - if (pipe(pfd) < 0) - return -errno; - - memset(link, 0, sizeof(*link)); - link->lk_rfd = pfd[0]; - link->lk_wfd = pfd[1]; - link->lk_group = group; - link->lk_uid = getpid(); - return 0; -} - -int libcfs_ukuc_stop(lustre_kernelcomm *link) -{ - if (link->lk_wfd > 0) - close(link->lk_wfd); - return close(link->lk_rfd); -} - -#define lhsz sizeof(*kuch) - -/** Read a message from the link. - * Allocates memory, returns handle - * - * @param link Private descriptor for pipe/socket. - * @param buf Buffer to read into, must include size for kuc_hdr - * @param maxsize Maximum message size allowed - * @param transport Only listen to messages on this transport - * (and the generic transport) - */ -int libcfs_ukuc_msg_get(lustre_kernelcomm *link, char *buf, int maxsize, - int transport) -{ - struct kuc_hdr *kuch; - int rc = 0; - - memset(buf, 0, maxsize); - - CDEBUG(D_KUC, "Waiting for message from kernel on fd %d\n", - link->lk_rfd); - - while (1) { - /* Read header first to get message size */ - rc = read(link->lk_rfd, buf, lhsz); - if (rc <= 0) { - rc = -errno; - break; - } - kuch = (struct kuc_hdr *)buf; - - CDEBUG(D_KUC, "Received message mg=%x t=%d m=%d l=%d\n", - kuch->kuc_magic, kuch->kuc_transport, kuch->kuc_msgtype, - kuch->kuc_msglen); - - if (kuch->kuc_magic != KUC_MAGIC) { - CERROR("bad message magic %x != %x\n", - kuch->kuc_magic, KUC_MAGIC); - rc = -EPROTO; - break; - } - - if (kuch->kuc_msglen > maxsize) { - rc = -EMSGSIZE; - break; - } - - /* Read payload */ - rc = read(link->lk_rfd, buf + lhsz, kuch->kuc_msglen - lhsz); - if (rc < 0) { - rc = -errno; - break; - } - if (rc < (kuch->kuc_msglen - lhsz)) { - CERROR("short read: got %d of %d bytes\n", - rc, kuch->kuc_msglen); - rc = -EPROTO; - break; - } - - if (kuch->kuc_transport == transport || - kuch->kuc_transport == KUC_TRANSPORT_GENERIC) { - return 0; - } - /* Drop messages for other transports */ - } - return rc; -} - -#else /* LUSTRE_UTILS */ /* This is the kernel side (liblustre as well). */ /** @@ -338,5 +238,3 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_foreach); - -#endif /* LUSTRE_UTILS */ From 72c0824a0bc07ff8dede86ef6800dd213eeab5d8 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 12 Feb 2014 19:21:39 +0800 Subject: [PATCH 0187/1375] staging/lustre/libcfs: remove cfs_hash_long Cc: Andreas Dilger Cc: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h | 2 -- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 2 +- drivers/staging/lustre/lustre/include/lustre_fid.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/lu_object.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c | 2 +- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index 9d5ee1a69c0c..e5d5db255622 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -65,8 +65,6 @@ #include -#define cfs_hash_long(val, bits) hash_long(val, bits) - /** disable debug */ #define CFS_HASH_DEBUG_NONE 0 /** record hash depth and output to console when it's too deep, diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 3ac2bb5fd2db..856fcfaafafa 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -628,7 +628,7 @@ void lnet_ni_free(lnet_ni_t *ni); static inline int lnet_nid2peerhash(lnet_nid_t nid) { - return cfs_hash_long(nid, LNET_PEER_HASH_BITS); + return hash_long(nid, LNET_PEER_HASH_BITS); } static inline struct list_head * diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index c562ff3e9283..a18fee56147b 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -770,7 +770,7 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number) if (number == 1) return 0; - val = cfs_hash_long(key, LNET_CPT_BITS); + val = hash_long(key, LNET_CPT_BITS); /* NB: LNET_CP_NUMBER doesn't have to be PO2 */ if (val < number) return val; diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 6fffd5e96f9c..920df69960a5 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -366,7 +366,7 @@ lnet_mt_match_head(struct lnet_match_table *mtable, unsigned long hash = mbits + id.nid + id.pid; LASSERT(lnet_ptl_is_unique(ptl)); - hash = cfs_hash_long(hash, LNET_MT_HASH_BITS); + hash = hash_long(hash, LNET_MT_HASH_BITS); return &mtable->mt_mhash[hash]; } } diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 84a897eed1df..cf78761356a4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -685,7 +685,7 @@ static inline __u32 fid_hash(const struct lu_fid *f, int bits) { /* all objects with same id and different versions will belong to same * collisions list. */ - return cfs_hash_long(fid_flatten(f), bits); + return hash_long(fid_flatten(f), bits); } /** diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 5f89864cda14..2824d4a9a85b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -421,9 +421,9 @@ static unsigned ldlm_res_hop_fid_hash(struct cfs_hash *hs, } else { val = fid_oid(&fid); } - hash = cfs_hash_long(hash, hs->hs_bkt_bits); + hash = hash_long(hash, hs->hs_bkt_bits); /* give me another random factor */ - hash -= cfs_hash_long((unsigned long)hs, val % 11 + 3); + hash -= hash_long((unsigned long)hs, val % 11 + 3); hash <<= hs->hs_cur_bits - hs->hs_bkt_bits; hash |= ldlm_res_hop_hash(hs, key, CFS_HASH_NBKT(hs) - 1); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 492964a38e7c..8800384c061c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -890,10 +890,10 @@ static unsigned lu_obj_hop_hash(struct cfs_hash *hs, hash = fid_flatten32(fid); hash += (hash >> 4) + (hash << 12); /* mixing oid and seq */ - hash = cfs_hash_long(hash, hs->hs_bkt_bits); + hash = hash_long(hash, hs->hs_bkt_bits); /* give me another random factor */ - hash -= cfs_hash_long((unsigned long)hs, fid_oid(fid) % 11 + 3); + hash -= hash_long((unsigned long)hs, fid_oid(fid) % 11 + 3); hash <<= hs->hs_cur_bits - hs->hs_bkt_bits; hash |= (fid_seq(fid) + fid_oid(fid)) & (CFS_HASH_NBKT(hs) - 1); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c index 8d25a70585dd..f0aba500764e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -102,7 +102,7 @@ static inline unsigned long hash_mem(char *buf, int length, int bits) len++; if ((len & (BITS_PER_LONG/8-1)) == 0) - hash = cfs_hash_long(hash^l, BITS_PER_LONG); + hash = hash_long(hash^l, BITS_PER_LONG); } while (len); return hash >> (BITS_PER_LONG - bits); From 7f46528c9d7d3e136b99fdee99134f894b0336c6 Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Wed, 12 Feb 2014 19:21:40 +0800 Subject: [PATCH 0188/1375] staging/lustre: fix coccinelle warnings drivers/staging/lustre/lustre/llite/dir.c:1416:2-8: Replace memcpy with struct assignment Generated by: coccinelle/misc/memcpy-assign.cocci CC: Peng Tao CC: Andreas Dilger CC: Oleg Drokin CC: Greg Kroah-Hartman Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 78ee3b118787..fd0dd20e1170 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1400,7 +1400,7 @@ lmv_out_free: if (tmp == NULL) GOTO(free_lmv, rc = -ENOMEM); - memcpy(tmp, &lum, sizeof(lum)); + *tmp = lum; tmp->lum_type = LMV_STRIPE_TYPE; tmp->lum_stripe_count = 1; mdtindex = ll_get_mdt_idx(inode); From 915064086e0189ed2aa69fddf14718aabbb541cb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:00 -0700 Subject: [PATCH 0189/1375] staging: comedi: introduce comedi_timeout() Introduce a comedi core helper function to handle the boilerplate needed by the drivers to busy- wait for a condition to occur. Typically this condition is the analog input/output end-of-conversion used with the comedi (*insn_read) and (*insn_write) operations. To use this function, the drivers just need to provide a callback that checks for the desired condition. The callback should return 0 if the condition is met or -EBUSY if it is still waiting. Any other errno will be returned to the caller. If the timeout occurs before the condition is met -ETIMEDOUT will be returned. The parameters to the callback function are the comedi_device, comedi_subdevice, and comedi_insn pointers that were passed to the (*insn_read) or (*insn_write) as well as an unsigned long, driver specific, 'context' that can be used to pass any other information that might be needed in the callback. This 'context' could be anything such as the register offset to read the status or the bits needed to check the status. The comedi_timeout() function itself does not use any of these parameters. This will help remove all the crazy "wait this many loops" used by some of the drivers. It also creates a common errno for comedi to detect when a timeout occurs. ADC/DAC conversion times are typically pretty fast, usually around 100K samples/sec (10 usec). A conservative timeout of 1 second is used in comedi_timeout(). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 8 ++++++++ drivers/staging/comedi/drivers.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index f82bd4256d51..f36bf3e02c41 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -353,6 +353,14 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, /* drivers.c - general comedi driver functions */ +#define COMEDI_TIMEOUT_MS 1000 + +int comedi_timeout(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, + int (*cb)(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned long context), + unsigned long context); + int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, unsigned int *data, unsigned int mask); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 5b15033a94bf..ab0e8ed47291 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -154,6 +154,36 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, return -EINVAL; } +/** + * comedi_timeout() - busy-wait for a driver condition to occur. + * @dev: comedi_device struct + * @s: comedi_subdevice struct + * @insn: comedi_insn struct + * @cb: callback to check for the condition + * @context: private context from the driver + */ +int comedi_timeout(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + int (*cb)(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context), + unsigned long context) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(COMEDI_TIMEOUT_MS); + int ret; + + while (time_before(jiffies, timeout)) { + ret = cb(dev, s, insn, context); + if (ret != -EBUSY) + return ret; /* success (0) or non EBUSY errno */ + cpu_relax(); + } + return -ETIMEDOUT; +} +EXPORT_SYMBOL_GPL(comedi_timeout); + /** * comedi_dio_insn_config() - boilerplate (*insn_config) for DIO subdevices. * @dev: comedi_device struct From f2426e4f72e70dec50741dce04014962a45d417d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:01 -0700 Subject: [PATCH 0190/1375] staging: comedi: skel: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Since this is the sample skeleton driver, add comments about how the callback function works with comedi_timeout(). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 39 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index e800e73738ee..a4933683a575 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -141,6 +141,29 @@ static int skel_ns_to_timer(unsigned int *ns, int round) return *ns; } +/* + * This function doesn't require a particular form, this is just + * what happens to be used in some of the drivers. The comedi_timeout() + * helper uses this callback to check for the end-of-conversion while + * waiting for up to 1 second. This function should return 0 when the + * conversion is finished and -EBUSY to keep waiting. Any other errno + * will terminate comedi_timeout() and return that errno to the caller. + * If the timeout occurs, comedi_timeout() will return -ETIMEDOUT. + */ +static int skel_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + /* status = inb(dev->iobase + SKEL_STATUS); */ + status = 1; + if (status) + return 0; + return -EBUSY; +} + /* * "instructions" read/write data in "one-shot" or "software-triggered" * mode. @@ -149,9 +172,9 @@ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { const struct skel_board *thisboard = comedi_board(dev); - int n, i; + int n; unsigned int d; - unsigned int status; + int ret; /* a typical programming sequence */ @@ -165,17 +188,11 @@ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* trigger conversion */ /* outw(0,dev->iobase + SKEL_CONVERT); */ -#define TIMEOUT 100 /* wait for conversion to end */ - for (i = 0; i < TIMEOUT; i++) { - status = 1; - /* status = inb(dev->iobase + SKEL_STATUS); */ - if (status) - break; - } - if (i == TIMEOUT) { + ret = comedi_timeout(dev, s, insn, skel_ai_eoc, 0); + if (ret) { dev_warn(dev->class_dev, "ai timeout\n"); - return -ETIMEDOUT; + return ret; } /* read data */ From 1f804706a65f4624cee275c3bdc7be1e5b394681 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:02 -0700 Subject: [PATCH 0191/1375] staging: comedi: adl_pci6208x: use comedi_timeout() Use comedi_timeout() to wait for the analog output end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci6208.c | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 5c1413abc52d..921f6942dfce 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -73,19 +73,17 @@ struct pci6208_private { unsigned int ao_readback[PCI6208_MAX_AO_CHANNELS]; }; -static int pci6208_ao_wait_for_data_send(struct comedi_device *dev, - unsigned int timeout) +static int pci6208_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { unsigned int status; - while (timeout--) { - status = inw(dev->iobase + PCI6208_AO_STATUS); - if ((status & PCI6208_AO_STATUS_DATA_SEND) == 0) - return 0; - udelay(1); - } - - return -ETIME; + status = inw(dev->iobase + PCI6208_AO_STATUS); + if ((status & PCI6208_AO_STATUS_DATA_SEND) == 0) + return 0; + return -EBUSY; } static int pci6208_ao_insn_write(struct comedi_device *dev, @@ -102,8 +100,8 @@ static int pci6208_ao_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { val = data[i]; - /* D/A transfer rate is 2.2us, wait up to 10us */ - ret = pci6208_ao_wait_for_data_send(dev, 10); + /* D/A transfer rate is 2.2us */ + ret = comedi_timeout(dev, s, insn, pci6208_ao_eoc, 0); if (ret) return ret; From fe45e153d424a009a22c0dfd86b0034926fd2342 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:03 -0700 Subject: [PATCH 0192/1375] staging: comedi: das16: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index a8446ca04110..6a7d652ff564 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -856,18 +856,17 @@ static void das16_ai_munge(struct comedi_device *dev, } } -static int das16_ai_wait_for_conv(struct comedi_device *dev, - unsigned int timeout) +static int das16_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { unsigned int status; - int i; - for (i = 0; i < timeout; i++) { - status = inb(dev->iobase + DAS16_STATUS_REG); - if (!(status & DAS16_STATUS_BUSY)) - return 0; - } - return -ETIME; + status = inb(dev->iobase + DAS16_STATUS_REG); + if ((status & DAS16_STATUS_BUSY) == 0) + return 0; + return -EBUSY; } static int das16_ai_insn_read(struct comedi_device *dev, @@ -897,7 +896,7 @@ static int das16_ai_insn_read(struct comedi_device *dev, /* trigger conversion */ outb_p(0, dev->iobase + DAS16_TRIG_REG); - ret = das16_ai_wait_for_conv(dev, 1000); + ret = comedi_timeout(dev, s, insn, das16_ai_eoc, 0); if (ret) return ret; From 90bc68ec9dec1e343ea7ac5e8ac8df5cd101947b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:04 -0700 Subject: [PATCH 0193/1375] staging: comedi: das800: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 5af0a5764a8c..dbe94cea5905 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -556,15 +556,17 @@ static irqreturn_t das800_interrupt(int irq, void *d) return IRQ_HANDLED; } -static int das800_wait_for_conv(struct comedi_device *dev, int timeout) +static int das800_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { - int i; + unsigned int status; - for (i = 0; i < timeout; i++) { - if (!(inb(dev->iobase + DAS800_STATUS) & BUSY)) - return 0; - } - return -ETIME; + status = inb(dev->iobase + DAS800_STATUS); + if ((status & BUSY) == 0) + return 0; + return -EBUSY; } static int das800_ai_insn_read(struct comedi_device *dev, @@ -599,7 +601,7 @@ static int das800_ai_insn_read(struct comedi_device *dev, /* trigger conversion */ outb_p(0, dev->iobase + DAS800_MSB); - ret = das800_wait_for_conv(dev, 1000); + ret = comedi_timeout(dev, s, insn, das800_ai_eoc, 0); if (ret) return ret; From 83b4d991253dd764cfcb46fb10ef73bbff913e47 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:05 -0700 Subject: [PATCH 0194/1375] staging: comedi: ii_pci20kc: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 8577778441fa..3558ab3b6e1f 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -190,20 +190,18 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, return insn->n; } -static int ii20k_ai_wait_eoc(struct comedi_device *dev, - struct comedi_subdevice *s, - int timeout) +static int ii20k_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned char status; - do { - status = readb(iobase + II20K_AI_STATUS_REG); - if ((status & II20K_AI_STATUS_INT) == 0) - return 0; - } while (timeout--); - - return -ETIME; + status = readb(iobase + II20K_AI_STATUS_REG); + if ((status & II20K_AI_STATUS_INT) == 0) + return 0; + return -EBUSY; } static void ii20k_ai_setup(struct comedi_device *dev, @@ -263,7 +261,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, /* generate a software start convert signal */ readb(iobase + II20K_AI_PACER_RESET_REG); - ret = ii20k_ai_wait_eoc(dev, s, 100); + ret = comedi_timeout(dev, s, insn, ii20k_ai_eoc, 0); if (ret) return ret; From acb069c04166bb65c681ef266956a178afdf04be Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:06 -0700 Subject: [PATCH 0195/1375] staging: comedi: mf6x4: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mf6x4.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/mf6x4.c b/drivers/staging/comedi/drivers/mf6x4.c index 81b78e053f4e..a4f7d6f138df 100644 --- a/drivers/staging/comedi/drivers/mf6x4.c +++ b/drivers/staging/comedi/drivers/mf6x4.c @@ -133,21 +133,18 @@ static int mf6x4_do_insn_bits(struct comedi_device *dev, return insn->n; } -static int mf6x4_ai_wait_for_eoc(struct comedi_device *dev, - unsigned int timeout) +static int mf6x4_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { struct mf6x4_private *devpriv = dev->private; - unsigned int eolc; + unsigned int status; - while (timeout--) { - eolc = ioread32(devpriv->gpioc_R) & MF6X4_GPIOC_EOLC; - if (eolc) - return 0; - - udelay(1); - } - - return -ETIME; + status = ioread32(devpriv->gpioc_R); + if (status & MF6X4_GPIOC_EOLC) + return 0; + return -EBUSY; } static int mf6x4_ai_insn_read(struct comedi_device *dev, @@ -168,7 +165,7 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev, /* Trigger ADC conversion by reading ADSTART */ ioread16(devpriv->bar1_mem + MF6X4_ADSTART_R); - ret = mf6x4_ai_wait_for_eoc(dev, 100); + ret = comedi_timeout(dev, s, insn, mf6x4_ai_eoc, 0); if (ret) return ret; From cf7b57fd6ab357198a327e0c74100e984bbf850f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:07 -0700 Subject: [PATCH 0196/1375] staging: comedi: ni_labpc: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 0512445df08e..037b46eb949f 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -73,7 +73,6 @@ #include "ni_labpc_isadma.h" #define LABPC_SIZE 0x20 /* size of ISA io region */ -#define LABPC_ADC_TIMEOUT 1000 enum scan_mode { MODE_SINGLE_CHAN, @@ -308,19 +307,17 @@ static void labpc_clear_adc_fifo(struct comedi_device *dev) labpc_read_adc_fifo(dev); } -static int labpc_ai_wait_for_data(struct comedi_device *dev, - int timeout) +static int labpc_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { struct labpc_private *devpriv = dev->private; - int i; - for (i = 0; i < timeout; i++) { - devpriv->stat1 = devpriv->read_byte(dev->iobase + STAT1_REG); - if (devpriv->stat1 & STAT1_DAVAIL) - return 0; - udelay(1); - } - return -ETIME; + devpriv->stat1 = devpriv->read_byte(dev->iobase + STAT1_REG); + if (devpriv->stat1 & STAT1_DAVAIL) + return 0; + return -EBUSY; } static int labpc_ai_insn_read(struct comedi_device *dev, @@ -363,7 +360,7 @@ static int labpc_ai_insn_read(struct comedi_device *dev, /* trigger conversion */ devpriv->write_byte(0x1, dev->iobase + ADC_START_CONVERT_REG); - ret = labpc_ai_wait_for_data(dev, LABPC_ADC_TIMEOUT); + ret = comedi_timeout(dev, s, insn, labpc_ai_eoc, 0); if (ret) return ret; From 37e2b25f143addf2ef2209eb85e5679885341063 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:08 -0700 Subject: [PATCH 0197/1375] staging: comedi: pcl711: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 659578881a4e..7c03a5d17b1b 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -253,18 +253,17 @@ static void pcl711_set_changain(struct comedi_device *dev, outb(mux | PCL711_MUX_CHAN(chan), dev->iobase + PCL711_MUX_REG); } -static int pcl711_ai_wait_for_eoc(struct comedi_device *dev, - unsigned int timeout) +static int pcl711_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { - unsigned int msb; + unsigned int status; - while (timeout--) { - msb = inb(dev->iobase + PCL711_AI_MSB_REG); - if ((msb & PCL711_AI_MSB_DRDY) == 0) - return 0; - udelay(1); - } - return -ETIME; + status = inb(dev->iobase + PCL711_AI_MSB_REG); + if ((status & PCL711_AI_MSB_DRDY) == 0) + return 0; + return -EBUSY; } static int pcl711_ai_insn_read(struct comedi_device *dev, @@ -282,7 +281,7 @@ static int pcl711_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { outb(PCL711_SOFTTRIG, dev->iobase + PCL711_SOFTTRIG_REG); - ret = pcl711_ai_wait_for_eoc(dev, 100); + ret = comedi_timeout(dev, s, insn, pcl711_ai_eoc, 0); if (ret) return ret; From 42946cfc55f5cff22744bf867111be074d1c658a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:09 -0700 Subject: [PATCH 0198/1375] staging: comedi: pcmad: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmad.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index fe482fdd512e..87c61d9b11da 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -61,18 +61,17 @@ static const struct pcmad_board_struct pcmad_boards[] = { }, }; -#define TIMEOUT 100 - -static int pcmad_ai_wait_for_eoc(struct comedi_device *dev, - int timeout) +static int pcmad_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { - int i; + unsigned int status; - for (i = 0; i < timeout; i++) { - if ((inb(dev->iobase + PCMAD_STATUS) & 0x3) == 0x3) - return 0; - } - return -ETIME; + status = inb(dev->iobase + PCMAD_STATUS); + if ((status & 0x3) == 0x3) + return 0; + return -EBUSY; } static int pcmad_ai_insn_read(struct comedi_device *dev, @@ -89,7 +88,7 @@ static int pcmad_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { outb(chan, dev->iobase + PCMAD_CONVERT); - ret = pcmad_ai_wait_for_eoc(dev, TIMEOUT); + ret = comedi_timeout(dev, s, insn, pcmad_ai_eoc, 0); if (ret) return ret; From 6fd13f761ca2e1747e0b136e241fb4aaab29f593 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:10 -0700 Subject: [PATCH 0199/1375] staging: comedi: pcmmio: use comedi_timeout() Use comedi_timeout() to wait for the analog input and output end-of- conversions. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 42 ++++++++++++++----------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index c388f7f32227..e89bca845349 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -589,16 +589,17 @@ static int pcmmio_cmdtest(struct comedi_device *dev, return 0; } -static int pcmmio_ai_wait_for_eoc(unsigned long iobase, unsigned int timeout) +static int pcmmio_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { unsigned char status; - while (timeout--) { - status = inb(iobase + PCMMIO_AI_STATUS_REG); - if (status & PCMMIO_AI_STATUS_DATA_READY) - return 0; - } - return -ETIME; + status = inb(dev->iobase + PCMMIO_AI_STATUS_REG); + if (status & PCMMIO_AI_STATUS_DATA_READY) + return 0; + return -EBUSY; } static int pcmmio_ai_insn_read(struct comedi_device *dev, @@ -643,7 +644,8 @@ static int pcmmio_ai_insn_read(struct comedi_device *dev, cmd |= PCMMIO_AI_CMD_RANGE(range); outb(cmd, iobase + PCMMIO_AI_CMD_REG); - ret = pcmmio_ai_wait_for_eoc(iobase, 100000); + + ret = comedi_timeout(dev, s, insn, pcmmio_ai_eoc, 0); if (ret) return ret; @@ -652,7 +654,8 @@ static int pcmmio_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { outb(cmd, iobase + PCMMIO_AI_CMD_REG); - ret = pcmmio_ai_wait_for_eoc(iobase, 100000); + + ret = comedi_timeout(dev, s, insn, pcmmio_ai_eoc, 0); if (ret) return ret; @@ -684,16 +687,17 @@ static int pcmmio_ao_insn_read(struct comedi_device *dev, return insn->n; } -static int pcmmio_ao_wait_for_eoc(unsigned long iobase, unsigned int timeout) +static int pcmmio_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { unsigned char status; - while (timeout--) { - status = inb(iobase + PCMMIO_AO_STATUS_REG); - if (status & PCMMIO_AO_STATUS_DATA_READY) - return 0; - } - return -ETIME; + status = inb(dev->iobase + PCMMIO_AO_STATUS_REG); + if (status & PCMMIO_AO_STATUS_DATA_READY) + return 0; + return -EBUSY; } static int pcmmio_ao_insn_write(struct comedi_device *dev, @@ -726,7 +730,8 @@ static int pcmmio_ao_insn_write(struct comedi_device *dev, outb(PCMMIO_AO_LSB_SPAN(range), iobase + PCMMIO_AO_LSB_REG); outb(0, iobase + PCMMIO_AO_MSB_REG); outb(cmd | PCMMIO_AO_CMD_WR_SPAN_UPDATE, iobase + PCMMIO_AO_CMD_REG); - ret = pcmmio_ao_wait_for_eoc(iobase, 100000); + + ret = comedi_timeout(dev, s, insn, pcmmio_ao_eoc, 0); if (ret) return ret; @@ -738,7 +743,8 @@ static int pcmmio_ao_insn_write(struct comedi_device *dev, outb((val >> 8) & 0xff, iobase + PCMMIO_AO_MSB_REG); outb(cmd | PCMMIO_AO_CMD_WR_CODE_UPDATE, iobase + PCMMIO_AO_CMD_REG); - ret = pcmmio_ao_wait_for_eoc(iobase, 100000); + + ret = comedi_timeout(dev, s, insn, pcmmio_ao_eoc, 0); if (ret) return ret; From 8a62fcbd2d4def1eae4b635dd2dfe7620f28e259 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:11 -0700 Subject: [PATCH 0200/1375] staging: comedi: dt2815: use comedi_timeout() Use comedi_timeout() to wait for the analog output end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2815.c | 39 +++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index ee24717821e1..1ab1dd76dfd7 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -67,15 +67,17 @@ struct dt2815_private { unsigned int ao_readback[8]; }; -static int dt2815_wait_for_status(struct comedi_device *dev, int status) +static int dt2815_ao_status(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { - int i; + unsigned int status; - for (i = 0; i < 100; i++) { - if (inb(dev->iobase + DT2815_STATUS) == status) - break; - } - return status; + status = inb(dev->iobase + DT2815_STATUS); + if (status == context) + return 0; + return -EBUSY; } static int dt2815_ao_insn_read(struct comedi_device *dev, @@ -98,30 +100,31 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct dt2815_private *devpriv = dev->private; int i; int chan = CR_CHAN(insn->chanspec); - unsigned int status; unsigned int lo, hi; + int ret; for (i = 0; i < insn->n; i++) { lo = ((data[i] & 0x0f) << 4) | (chan << 1) | 0x01; hi = (data[i] & 0xff0) >> 4; - status = dt2815_wait_for_status(dev, 0x00); - if (status != 0) { + ret = comedi_timeout(dev, s, insn, dt2815_ao_status, 0x00); + if (ret) { dev_dbg(dev->class_dev, - "failed to write low byte on %d reason %x\n", - chan, status); - return -EBUSY; + "failed to write low byte on %d\n", + chan); + return ret; } outb(lo, dev->iobase + DT2815_DATA); - status = dt2815_wait_for_status(dev, 0x10); - if (status != 0x10) { + ret = comedi_timeout(dev, s, insn, dt2815_ao_status, 0x10); + if (ret) { dev_dbg(dev->class_dev, - "failed to write high byte on %d reason %x\n", - chan, status); - return -EBUSY; + "failed to write high byte on %d\n", + chan); + return ret; } + devpriv->ao_readback[chan] = data[i]; } return i; From 8c5bd90e9fa8bb74ed94b969e6305b8560637417 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:12 -0700 Subject: [PATCH 0201/1375] staging: comedi: rti800: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Change the errno returned for an overrun from -EIO to -EOVERFLOW. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rti800.c | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index e1f3671ac056..bd447b2add7b 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -83,8 +83,6 @@ #define RTI800_IOSIZE 0x10 -#define RTI800_AI_TIMEOUT 100 - static const struct comedi_lrange range_rti800_ai_10_bipolar = { 4, { BIP_RANGE(10), @@ -145,23 +143,21 @@ struct rti800_private { unsigned char muxgain_bits; }; -static int rti800_ai_wait_for_conversion(struct comedi_device *dev, - int timeout) +static int rti800_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { unsigned char status; - int i; - for (i = 0; i < timeout; i++) { - status = inb(dev->iobase + RTI800_CSR); - if (status & RTI800_CSR_OVERRUN) { - outb(0, dev->iobase + RTI800_CLRFLAGS); - return -EIO; - } - if (status & RTI800_CSR_DONE) - return 0; - udelay(1); + status = inb(dev->iobase + RTI800_CSR); + if (status & RTI800_CSR_OVERRUN) { + outb(0, dev->iobase + RTI800_CLRFLAGS); + return -EOVERFLOW; } - return -ETIME; + if (status & RTI800_CSR_DONE) + return 0; + return -EBUSY; } static int rti800_ai_insn_read(struct comedi_device *dev, @@ -198,7 +194,8 @@ static int rti800_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { outb(0, dev->iobase + RTI800_CONVERT); - ret = rti800_ai_wait_for_conversion(dev, RTI800_AI_TIMEOUT); + + ret = comedi_timeout(dev, s, insn, rti800_ai_eoc, 0); if (ret) return ret; From 0862a46f173132cab7508ae0534b9a85fd4cc35c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:13 -0700 Subject: [PATCH 0202/1375] staging: comedi: aio_aio12_8: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/aio_aio12_8.c | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index e2a917786f0a..3f994ed3db42 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -101,14 +101,27 @@ struct aio12_8_private { unsigned int ao_readback[4]; }; +static int aio_aio12_8_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + AIO12_8_STATUS_REG); + if (status & AIO12_8_STATUS_ADC_EOC) + return 0; + return -EBUSY; +} + static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); - unsigned int val; unsigned char control; + int ret; int n; /* @@ -122,20 +135,15 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, inb(dev->iobase + AIO12_8_STATUS_REG); for (n = 0; n < insn->n; n++) { - int timeout = 5; - /* Setup and start conversion */ outb(control, dev->iobase + AIO12_8_ADC_REG); /* Wait for conversion to complete */ - do { - val = inb(dev->iobase + AIO12_8_STATUS_REG); - timeout--; - if (timeout == 0) { - dev_err(dev->class_dev, "ADC timeout\n"); - return -ETIMEDOUT; - } - } while (!(val & AIO12_8_STATUS_ADC_EOC)); + ret = comedi_timeout(dev, s, insn, aio_aio12_8_ai_eoc, 0); + if (ret) { + dev_err(dev->class_dev, "ADC timeout\n"); + return ret; + } data[n] = inw(dev->iobase + AIO12_8_ADC_REG) & s->maxdata; } From e467bc37df212613b5b0fda9b262ffe548505986 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:14 -0700 Subject: [PATCH 0203/1375] staging: comedi: cb_das16_cs: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_das16_cs.c | 26 ++++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 9a14e26e2416..549844cf2b35 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -101,6 +101,19 @@ static irqreturn_t das16cs_interrupt(int irq, void *d) return IRQ_HANDLED; } +static int das16cs_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + DAS16CS_MISC1); + if (status & 0x0080) + return 0; + return -EBUSY; +} + static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -109,8 +122,8 @@ static int das16cs_ai_rinsn(struct comedi_device *dev, int chan = CR_CHAN(insn->chanspec); int range = CR_RANGE(insn->chanspec); int aref = CR_AREF(insn->chanspec); + int ret; int i; - int to; outw(chan, dev->iobase + DAS16CS_DIO_MUX); @@ -138,15 +151,12 @@ static int das16cs_ai_rinsn(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { outw(0, dev->iobase + DAS16CS_ADC_DATA); -#define TIMEOUT 1000 - for (to = 0; to < TIMEOUT; to++) { - if (inw(dev->iobase + DAS16CS_MISC1) & 0x0080) - break; - } - if (to == TIMEOUT) { + ret = comedi_timeout(dev, s, insn, das16cs_ai_eoc, 0); + if (ret) { dev_dbg(dev->class_dev, "cb_das16_cs: ai timeout\n"); - return -ETIME; + return ret; } + data[i] = inw(dev->iobase + DAS16CS_ADC_DATA); } From 06cb9ba887d07e80ac51d8a233d56e5fd39bc175 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:15 -0700 Subject: [PATCH 0204/1375] staging: comedi: cb_pcidas: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 69fbda7e3bc2..7d068ebe0575 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -376,6 +376,20 @@ static inline unsigned int cal_enable_bits(struct comedi_device *dev) return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source); } +static int cb_pcidas_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct cb_pcidas_private *devpriv = dev->private; + unsigned int status; + + status = inw(devpriv->control_status + ADCMUX_CONT); + if (status & EOC) + return 0; + return -EBUSY; +} + static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -385,7 +399,8 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, unsigned int range = CR_RANGE(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec); unsigned int bits; - int n, i; + int ret; + int n; /* enable calibration input if appropriate */ if (insn->chanspec & CR_ALT_SOURCE) { @@ -415,13 +430,9 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, outw(0, devpriv->adc_fifo + ADCDATA); /* wait for conversion to end */ - /* return -ETIMEDOUT if there is a timeout */ - for (i = 0; i < 10000; i++) { - if (inw(devpriv->control_status + ADCMUX_CONT) & EOC) - break; - } - if (i == 10000) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, cb_pcidas_ai_eoc, 0); + if (ret) + return ret; /* read data */ data[n] = inw(devpriv->adc_fifo + ADCDATA); From 96ed0850fffa361f922b081effe676b637241bee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:16 -0700 Subject: [PATCH 0205/1375] staging: comedi: cb_pcidas64: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 44 ++++++++++++-------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 464c783e566e..21e13a5cea11 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1664,15 +1664,36 @@ static void i2c_write(struct comedi_device *dev, unsigned int address, i2c_stop(dev); } +static int cb_pcidas64_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + const struct pcidas64_board *thisboard = comedi_board(dev); + struct pcidas64_private *devpriv = dev->private; + unsigned int status; + + status = readw(devpriv->main_iobase + HW_STATUS_REG); + if (thisboard->layout == LAYOUT_4020) { + status = readw(devpriv->main_iobase + ADC_WRITE_PNTR_REG); + if (status) + return 0; + } else { + if (pipe_full_bits(status)) + return 0; + } + return -EBUSY; +} + static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { const struct pcidas64_board *thisboard = comedi_board(dev); struct pcidas64_private *devpriv = dev->private; - unsigned int bits = 0, n, i; + unsigned int bits = 0, n; unsigned int channel, range, aref; unsigned long flags; - static const int timeout = 100; + int ret; channel = CR_CHAN(insn->chanspec); range = CR_RANGE(insn->chanspec); @@ -1770,23 +1791,12 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, devpriv->main_iobase + ADC_CONVERT_REG); /* wait for data */ - for (i = 0; i < timeout; i++) { - bits = readw(devpriv->main_iobase + HW_STATUS_REG); - if (thisboard->layout == LAYOUT_4020) { - if (readw(devpriv->main_iobase + - ADC_WRITE_PNTR_REG)) - break; - } else { - if (pipe_full_bits(bits)) - break; - } - udelay(1); - } - if (i == timeout) { + ret = comedi_timeout(dev, s, insn, cb_pcidas64_ai_eoc, 0); + if (ret) { comedi_error(dev, " analog input read insn timed out"); - dev_info(dev->class_dev, "status 0x%x\n", bits); - return -ETIME; + return ret; } + if (thisboard->layout == LAYOUT_4020) data[n] = readl(devpriv->dio_counter_iobase + ADC_FIFO_REG) & 0xffff; From 6976a449cd201b210aa2804aecde590d5610a71b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:17 -0700 Subject: [PATCH 0206/1375] staging: comedi: cb_pcimdas: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Remove the unnecessary comments. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdas.c | 35 +++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 3e39cb593e10..d3141c865fe7 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -85,21 +85,31 @@ struct cb_pcimdas_private { unsigned int ao_readback[2]; }; -/* - * "instructions" read/write data in "one-shot" or "software-triggered" - * mode. - */ +static int cb_pcimdas_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct cb_pcimdas_private *devpriv = dev->private; + unsigned int status; + + status = inb(devpriv->BADR3 + 2); + if ((status & 0x80) == 0) + return 0; + return -EBUSY; +} + static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct cb_pcimdas_private *devpriv = dev->private; - int n, i; + int n; unsigned int d; - unsigned int busy; int chan = CR_CHAN(insn->chanspec); unsigned short chanlims; int maxchans; + int ret; /* only support sw initiated reads from a single channel */ @@ -133,17 +143,10 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, /* trigger conversion */ outw(0, dev->iobase + 0); -#define TIMEOUT 1000 /* typically takes 5 loops on a lightly loaded Pentium 100MHz, */ - /* this is likely to be 100 loops on a 2GHz machine, so set 1000 as the limit. */ - /* wait for conversion to end */ - for (i = 0; i < TIMEOUT; i++) { - busy = inb(devpriv->BADR3 + 2) & 0x80; - if (!busy) - break; - } - if (i == TIMEOUT) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, cb_pcimdas_ai_eoc, 0); + if (ret) + return ret; /* read data */ data[n] = inw(dev->iobase + 0); From c3ce086e15e67dc140371a0bacced4cf8a012386 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:18 -0700 Subject: [PATCH 0207/1375] staging: comedi: das08: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 3c0e45837c72..b9916315adc6 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -201,17 +201,29 @@ static const int *const das08_gainlists[] = { das08_pgm_gainlist, }; -#define TIMEOUT 100000 +static int das08_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + DAS08_STATUS); + if ((status & DAS08_EOC) == 0) + return 0; + return -EBUSY; +} static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { const struct das08_board_struct *thisboard = comedi_board(dev); struct das08_private_struct *devpriv = dev->private; - int i, n; + int n; int chan; int range; int lsb, msb; + int ret; chan = CR_CHAN(insn->chanspec); range = CR_RANGE(insn->chanspec); @@ -244,14 +256,12 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* trigger conversion */ outb_p(0, dev->iobase + DAS08_TRIG_12BIT); - for (i = 0; i < TIMEOUT; i++) { - if (!(inb(dev->iobase + DAS08_STATUS) & DAS08_EOC)) - break; - } - if (i == TIMEOUT) { + ret = comedi_timeout(dev, s, insn, das08_ai_eoc, 0); + if (ret) { dev_err(dev->class_dev, "timeout\n"); - return -ETIME; + return ret; } + msb = inb(dev->iobase + DAS08_MSB); lsb = inb(dev->iobase + DAS08_LSB); if (thisboard->ai_encoding == das08_encode12) { From ab984177b3c3ff5b59b08306cdd2ac3ef794e571 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:19 -0700 Subject: [PATCH 0208/1375] staging: comedi: das16m1: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index fee5facff8dd..a94b7a4e495e 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -331,14 +331,27 @@ static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } +static int das16m1_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + DAS16M1_CS); + if (status & IRQDATA) + return 0; + return -EBUSY; +} + static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct das16m1_private_struct *devpriv = dev->private; - int i, n; + int ret; + int n; int byte; - const int timeout = 1000; /* disable interrupts and internal pacer */ devpriv->control_state &= ~INTE & ~PACER_MASK; @@ -356,14 +369,12 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, /* trigger conversion */ outb(0, dev->iobase); - for (i = 0; i < timeout; i++) { - if (inb(dev->iobase + DAS16M1_CS) & IRQDATA) - break; - } - if (i == timeout) { + ret = comedi_timeout(dev, s, insn, das16m1_ai_eoc, 0); + if (ret) { comedi_error(dev, "timeout"); - return -ETIME; + return ret; } + data[n] = munge_sample(inw(dev->iobase)); } From 7c4ede3a6baa640393c7e98f9271c6c282a02f1e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:20 -0700 Subject: [PATCH 0209/1375] staging: comedi: dt2811: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 4271903facd7..ba7c2ba618e6 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -224,23 +224,32 @@ static const struct comedi_lrange *dac_range_types[] = { &range_unipolar5 }; -#define DT2811_TIMEOUT 5 +static int dt2811_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + DT2811_ADCSR); + if ((status & DT2811_ADBUSY) == 0) + return 0; + return -EBUSY; +} static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { int chan = CR_CHAN(insn->chanspec); - int timeout = DT2811_TIMEOUT; + int ret; int i; for (i = 0; i < insn->n; i++) { outb(chan, dev->iobase + DT2811_ADGCR); - while (timeout - && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY) - timeout--; - if (!timeout) - return -ETIME; + ret = comedi_timeout(dev, s, insn, dt2811_ai_eoc, 0); + if (ret) + return ret; data[i] = inb(dev->iobase + DT2811_ADDATLO); data[i] |= inb(dev->iobase + DT2811_ADDATHI) << 8; From 65a1c97f1eea5da72ef6b089764721154b4d8d1f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:21 -0700 Subject: [PATCH 0210/1375] staging: comedi: me_daq: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me_daq.c | 35 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 288ce2b16e8f..288fb21b6f65 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -248,6 +248,20 @@ static int me_dio_insn_bits(struct comedi_device *dev, return insn->n; } +static int me_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct me_private_data *dev_private = dev->private; + unsigned int status; + + status = readw(dev_private->me_regbase + ME_STATUS); + if ((status & 0x0004) == 0) + return 0; + return -EBUSY; +} + static int me_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -258,7 +272,7 @@ static int me_ai_insn_read(struct comedi_device *dev, unsigned int rang = CR_RANGE(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec); unsigned short val; - int i; + int ret; /* stop any running conversion */ dev_private->control_1 &= 0xFFFC; @@ -290,19 +304,16 @@ static int me_ai_insn_read(struct comedi_device *dev, readw(dev_private->me_regbase + ME_ADC_START); /* wait for ADC fifo not empty flag */ - for (i = 100000; i > 0; i--) - if (!(readw(dev_private->me_regbase + ME_STATUS) & 0x0004)) - break; + ret = comedi_timeout(dev, s, insn, me_ai_eoc, 0); + if (ret) { + dev_err(dev->class_dev, "Cannot get single value\n"); + return ret; + } /* get value from ADC fifo */ - if (i) { - val = readw(dev_private->me_regbase + ME_READ_AD_FIFO); - val = (val ^ 0x800) & 0x0fff; - data[0] = val; - } else { - dev_err(dev->class_dev, "Cannot get single value\n"); - return -EIO; - } + val = readw(dev_private->me_regbase + ME_READ_AD_FIFO); + val = (val ^ 0x800) & 0x0fff; + data[0] = val; /* stop any running conversion */ dev_private->control_1 &= 0xFFFC; From 3d21960b6dd6bc68d3312be77c9a7a60a0857b90 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:22 -0700 Subject: [PATCH 0211/1375] staging: comedi: mpc624: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mpc624.c | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index 59ad8391cdc8..f770400a0e81 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -142,8 +142,18 @@ static const struct comedi_lrange range_mpc624_bipolar10 = { } }; -/* Timeout 200ms */ -#define TIMEOUT 200 +static int mpc624_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned char status; + + status = inb(dev->iobase + MPC624_ADC); + if ((status & MPC624_ADBUSY) == 0) + return 0; + return -EBUSY; +} static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -152,7 +162,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct mpc624_private *devpriv = dev->private; int n, i; unsigned long int data_in, data_out; - unsigned char ucPort; + int ret; /* * WARNING: @@ -170,15 +180,9 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, udelay(1); /* Wait for the conversion to end */ - for (i = 0; i < TIMEOUT; i++) { - ucPort = inb(dev->iobase + MPC624_ADC); - if (ucPort & MPC624_ADBUSY) - udelay(1000); - else - break; - } - if (i == TIMEOUT) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, mpc624_ai_eoc, 0); + if (ret) + return ret; /* Start reading data */ data_in = 0; From 043fff873dfeac74c977f4f09b6e4a015643d23f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:23 -0700 Subject: [PATCH 0212/1375] staging: comedi: s526: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s526.c | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 0a93afab3dcb..85d2b7a3c125 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -420,15 +420,28 @@ static int s526_ai_insn_config(struct comedi_device *dev, return result; } +static int s526_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + REG_ISR); + if (status & ISR_ADC_DONE) + return 0; + return -EBUSY; +} + static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct s526_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - int n, i; + int n; unsigned short value; unsigned int d; - unsigned int status; + int ret; /* Set configured delay, enable channel for this channel only, * select "ADC read" channel, set "ADC start" bit. */ @@ -440,17 +453,12 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* trigger conversion */ outw(value, dev->iobase + REG_ADC); -#define TIMEOUT 100 /* wait for conversion to end */ - for (i = 0; i < TIMEOUT; i++) { - status = inw(dev->iobase + REG_ISR); - if (status & ISR_ADC_DONE) { - outw(ISR_ADC_DONE, dev->iobase + REG_ISR); - break; - } - } - if (i == TIMEOUT) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, s526_ai_eoc, 0); + if (ret) + return ret; + + outw(ISR_ADC_DONE, dev->iobase + REG_ISR); /* read data */ d = inw(dev->iobase + REG_ADD); From 67562be5054f325324197cfd0f478cdc76ed57e8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:24 -0700 Subject: [PATCH 0213/1375] staging: comedi: addi_apci_3xx: use comedi_timeout() Use comedi_timeout() to wait for the analog input and output end-of- conversions. This prevents a deadlock condition that could occur by providing a timeout in case the end-of-conversion does not happen. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi_apci_3xxx.c | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 1f3b668f7f1f..6dc11c407f57 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -434,13 +434,26 @@ static int apci3xxx_ai_setup(struct comedi_device *dev, unsigned int chanspec) return 0; } +static int apci3xxx_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct apci3xxx_private *devpriv = dev->private; + unsigned int status; + + status = readl(devpriv->mmio + 20); + if (status & 0x1) + return 0; + return -EBUSY; +} + static int apci3xxx_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct apci3xxx_private *devpriv = dev->private; - unsigned int val; int ret; int i; @@ -453,10 +466,9 @@ static int apci3xxx_ai_insn_read(struct comedi_device *dev, writel(0x80000, devpriv->mmio + 8); /* Wait the EOS */ - do { - val = readl(devpriv->mmio + 20); - val &= 0x1; - } while (!val); + ret = comedi_timeout(dev, s, insn, apci3xxx_ai_eoc, 0); + if (ret) + return ret; /* Read the analog value */ data[i] = readl(devpriv->mmio + 28); @@ -622,6 +634,20 @@ static int apci3xxx_ai_cancel(struct comedi_device *dev, return 0; } +static int apci3xxx_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct apci3xxx_private *devpriv = dev->private; + unsigned int status; + + status = readl(devpriv->mmio + 96); + if (status & 0x100) + return 0; + return -EBUSY; +} + static int apci3xxx_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -630,7 +656,7 @@ static int apci3xxx_ao_insn_write(struct comedi_device *dev, struct apci3xxx_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); - unsigned int status; + int ret; int i; for (i = 0; i < insn->n; i++) { @@ -641,9 +667,9 @@ static int apci3xxx_ao_insn_write(struct comedi_device *dev, writel((data[i] << 8) | chan, devpriv->mmio + 100); /* Wait the end of transfer */ - do { - status = readl(devpriv->mmio + 96); - } while ((status & 0x100) != 0x100); + ret = comedi_timeout(dev, s, insn, apci3xxx_ao_eoc, 0); + if (ret) + return ret; } return insn->n; From 33a6d44bbdf24d84833736ea691555f8c459f0c6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:25 -0700 Subject: [PATCH 0214/1375] staging: comedi: ni_at_a2150: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 42 +++++++++++--------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index f83eb9ebe278..07239c967f9d 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -488,13 +488,25 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } +static int a2150_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + STATUS_REG); + if (status & FNE_BIT) + return 0; + return -EBUSY; +} + static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct a2150_private *devpriv = dev->private; - unsigned int i, n; - static const int timeout = 100000; - static const int filter_delay = 36; + unsigned int n; + int ret; /* clear fifo and reset triggering circuitry */ outw(0, dev->iobase + FIFO_RESET_REG); @@ -524,30 +536,24 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, * there is a 35.6 sample delay for data to get through the * antialias filter */ - for (n = 0; n < filter_delay; n++) { - for (i = 0; i < timeout; i++) { - if (inw(dev->iobase + STATUS_REG) & FNE_BIT) - break; - udelay(1); - } - if (i == timeout) { + for (n = 0; n < 36; n++) { + ret = comedi_timeout(dev, s, insn, a2150_ai_eoc, 0); + if (ret) { comedi_error(dev, "timeout"); - return -ETIME; + return ret; } + inw(dev->iobase + FIFO_DATA_REG); } /* read data */ for (n = 0; n < insn->n; n++) { - for (i = 0; i < timeout; i++) { - if (inw(dev->iobase + STATUS_REG) & FNE_BIT) - break; - udelay(1); - } - if (i == timeout) { + ret = comedi_timeout(dev, s, insn, a2150_ai_eoc, 0); + if (ret) { comedi_error(dev, "timeout"); - return -ETIME; + return ret; } + data[n] = inw(dev->iobase + FIFO_DATA_REG); data[n] ^= 0x8000; } From 03ff5898c715e202f154a5259aed46f64ef9a86e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:26 -0700 Subject: [PATCH 0215/1375] staging: comedi: ni_atmio16d: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Change the errno returned when the conversion overflows from -ETIME to -EOVERFLOW. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_atmio16d.c | 52 +++++++++++--------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 4f26aa9424b8..4262385e4f46 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -96,7 +96,6 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d) #define CLOCK_100_HZ 0x8F25 /* Other miscellaneous defines */ #define ATMIO16D_SIZE 32 /* bus address range */ -#define ATMIO16D_TIMEOUT 10 struct atmio16_board_t { @@ -448,16 +447,32 @@ static int atmio16d_ai_cancel(struct comedi_device *dev, return 0; } -/* Mode 0 is used to get a single conversion on demand */ +static int atmio16d_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + STAT_REG); + if (status & STAT_AD_CONVAVAIL) + return 0; + if (status & STAT_AD_OVERFLOW) { + outw(0, dev->iobase + AD_CLEAR_REG); + return -EOVERFLOW; + } + return -EBUSY; +} + static int atmio16d_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct atmio16d_private *devpriv = dev->private; - int i, t; + int i; int chan; int gain; - int status; + int ret; chan = CR_CHAN(insn->chanspec); gain = CR_RANGE(insn->chanspec); @@ -473,26 +488,17 @@ static int atmio16d_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { /* start the conversion */ outw(0, dev->iobase + START_CONVERT_REG); + /* wait for it to finish */ - for (t = 0; t < ATMIO16D_TIMEOUT; t++) { - /* check conversion status */ - status = inw(dev->iobase + STAT_REG); - if (status & STAT_AD_CONVAVAIL) { - /* read the data now */ - data[i] = inw(dev->iobase + AD_FIFO_REG); - /* change to two's complement if need be */ - if (devpriv->adc_coding == adc_2comp) - data[i] ^= 0x800; - break; - } - if (status & STAT_AD_OVERFLOW) { - outw(0, dev->iobase + AD_CLEAR_REG); - return -ETIME; - } - } - /* end waiting, now check if it timed out */ - if (t == ATMIO16D_TIMEOUT) - return -ETIME; + ret = comedi_timeout(dev, s, insn, atmio16d_ai_eoc, 0); + if (ret) + return ret; + + /* read the data now */ + data[i] = inw(dev->iobase + AD_FIFO_REG); + /* change to two's complement if need be */ + if (devpriv->adc_coding == adc_2comp) + data[i] ^= 0x800; } return i; From 5e1a65aec69d96affd89241f1a618dd6b552de79 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:27 -0700 Subject: [PATCH 0216/1375] staging: comedi: adl_pci9111: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 36 +++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 0039b1b0ec47..c741e8a04146 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -84,7 +84,6 @@ TODO: #define PCI9111_RANGE_SETTING_DELAY 10 #define PCI9111_AI_INSTANT_READ_UDELAY_US 2 -#define PCI9111_AI_INSTANT_READ_TIMEOUT 100 /* * IO address map and bit defines @@ -707,6 +706,19 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) return IRQ_HANDLED; } +static int pci9111_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + PCI9111_AI_RANGE_STAT_REG); + if (status & PCI9111_AI_STAT_FF_EF) + return 0; + return -EBUSY; +} + static int pci9111_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -717,7 +729,7 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, unsigned int invert = (maxdata + 1) >> 1; unsigned int shift = (maxdata == 0xffff) ? 0 : 4; unsigned int status; - int timeout; + int ret; int i; outb(chan, dev->iobase + PCI9111_AI_CHANNEL_REG); @@ -734,22 +746,14 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, /* Generate a software trigger */ outb(0, dev->iobase + PCI9111_SOFT_TRIG_REG); - timeout = PCI9111_AI_INSTANT_READ_TIMEOUT; - - while (timeout--) { - status = inb(dev->iobase + PCI9111_AI_RANGE_STAT_REG); - /* '1' means FIFO is not empty */ - if (status & PCI9111_AI_STAT_FF_EF) - goto conversion_done; + ret = comedi_timeout(dev, s, insn, pci9111_ai_eoc, 0); + if (ret) { + comedi_error(dev, "A/D read timeout"); + data[i] = 0; + pci9111_fifo_reset(dev); + return ret; } - comedi_error(dev, "A/D read timeout"); - data[i] = 0; - pci9111_fifo_reset(dev); - return -ETIME; - -conversion_done: - data[i] = inw(dev->iobase + PCI9111_AI_FIFO_REG); data[i] = ((data[i] >> shift) & maxdata) ^ invert; } From e934b994efcffd3c27579593e9dfae88d5c59b2b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:28 -0700 Subject: [PATCH 0217/1375] staging: comedi: adl_pci9118: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 34 +++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index ef5afdb3bd09..6492bd81efe8 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -571,12 +571,26 @@ static int setup_channel_list(struct comedi_device *dev, return 1; /* we can serve this with scan logic */ } +static int pci9118_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inl(dev->iobase + PCI9118_ADSTAT); + if (status & AdStatus_ADrdy) + return 0; + return -EBUSY; +} + static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct pci9118_private *devpriv = dev->private; - int n, timeout; + int ret; + int n; devpriv->AdControlReg = AdControl_Int & 0xff; devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; @@ -597,19 +611,15 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { outw(0, dev->iobase + PCI9118_SOFTTRG); /* start conversion */ udelay(2); - timeout = 100; - while (timeout--) { - if (inl(dev->iobase + PCI9118_ADSTAT) & AdStatus_ADrdy) - goto conv_finish; - udelay(1); + + ret = comedi_timeout(dev, s, insn, pci9118_ai_eoc, 0); + if (ret) { + comedi_error(dev, "A/D insn timeout"); + data[n] = 0; + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + return ret; } - comedi_error(dev, "A/D insn timeout"); - data[n] = 0; - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ - return -ETIME; - -conv_finish: if (devpriv->ai16bits) { data[n] = (inl(dev->iobase + From fa3fa1dea68e43599657bb06610e258299e19f2e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:29 -0700 Subject: [PATCH 0218/1375] staging: comedi: adv_pci1710: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 40 ++++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index f9d6111110cb..36ed579cdd95 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -429,15 +429,26 @@ static void setup_channel_list(struct comedi_device *dev, outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); } -/* -============================================================================== -*/ +static int pci171x_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + PCI171x_STATUS); + if ((status & Status_FE) == 0) + return 0; + return -EBUSY; +} + static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct pci1710_private *devpriv = dev->private; - int n, timeout; + int ret; + int n; #ifdef PCI171x_PARANOIDCHECK const struct boardtype *this_board = comedi_board(dev); unsigned int idata; @@ -453,19 +464,16 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { outw(0, dev->iobase + PCI171x_SOFTTRG); /* start conversion */ - /* udelay(1); */ - timeout = 100; - while (timeout--) { - if (!(inw(dev->iobase + PCI171x_STATUS) & Status_FE)) - goto conv_finish; - } - comedi_error(dev, "A/D insn timeout"); - outb(0, dev->iobase + PCI171x_CLRFIFO); - outb(0, dev->iobase + PCI171x_CLRINT); - data[n] = 0; - return -ETIME; -conv_finish: + ret = comedi_timeout(dev, s, insn, pci171x_ai_eoc, 0); + if (ret) { + comedi_error(dev, "A/D insn timeout"); + outb(0, dev->iobase + PCI171x_CLRFIFO); + outb(0, dev->iobase + PCI171x_CLRINT); + data[n] = 0; + return ret; + } + #ifdef PCI171x_PARANOIDCHECK idata = inw(dev->iobase + PCI171x_AD_DATA); if (this_board->cardtype != TYPE_PCI1713) From 5cc0387c1972ab68dc8ced245a6da18bc565c0c0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:30 -0700 Subject: [PATCH 0219/1375] staging: comedi: adq12b: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. This also fixes a possible bug where invalid data is returned if the conversion did not complete. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adq12b.c | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index 3190ef7d285e..b4ea37704eaf 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -94,8 +94,6 @@ If you do not specify any options, they will default to /* mask of the bit at STINR to check end of conversion */ #define ADQ12B_EOC 0x20 -#define TIMEOUT 20 - /* available ranges through the PGA gains */ static const struct comedi_lrange range_adq12b_ai_bipolar = { 4, { @@ -122,19 +120,28 @@ struct adq12b_private { int last_range; }; -/* - * "instructions" read/write data in "one-shot" or "software-triggered" - * mode. - */ +static int adq12b_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned char status; + + status = inb(dev->iobase + ADQ12B_STINR); + if (status & ADQ12B_EOC) + return 0; + return -EBUSY; +} static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct adq12b_private *devpriv = dev->private; - int n, i; + int n; int range, channel; unsigned char hi, lo, status; + int ret; /* change channel and range only if it is different from the previous */ range = CR_RANGE(insn->chanspec); @@ -151,13 +158,9 @@ static int adq12b_ai_rinsn(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { /* wait for end of conversion */ - i = 0; - do { - /* udelay(1); */ - status = inb(dev->iobase + ADQ12B_STINR); - status = status & ADQ12B_EOC; - } while (status == 0 && ++i < TIMEOUT); - /* } while (++i < 10); */ + ret = comedi_timeout(dev, s, insn, adq12b_ai_eoc, 0); + if (ret) + return ret; /* read data */ hi = inb(dev->iobase + ADQ12B_ADHIG); From 0883fcab44dd5a70b800d700dc23144b0734f77d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:31 -0700 Subject: [PATCH 0220/1375] staging: comedi: amplc_pci230: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 7356fee67379..b606bdb2826e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -799,19 +799,29 @@ static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct) /* Counter ct, 8254 mode 1, initial count not written. */ } -/* - * COMEDI_SUBD_AI instruction; - */ +static int pci230_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + PCI230_ADCCON); + if ((status & PCI230_ADC_FIFO_EMPTY) == 0) + return 0; + return -EBUSY; +} + static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct pci230_private *devpriv = dev->private; - unsigned int n, i; + unsigned int n; unsigned int chan, range, aref; unsigned int gainshift; - unsigned int status; unsigned short adccon, adcen; + int ret; /* Unpack channel and range. */ chan = CR_CHAN(insn->chanspec); @@ -883,17 +893,11 @@ static int pci230_ai_rinsn(struct comedi_device *dev, i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE1); -#define TIMEOUT 100 /* wait for conversion to end */ - for (i = 0; i < TIMEOUT; i++) { - status = inw(dev->iobase + PCI230_ADCCON); - if (!(status & PCI230_ADC_FIFO_EMPTY)) - break; - udelay(1); - } - if (i == TIMEOUT) { + ret = comedi_timeout(dev, s, insn, pci230_ai_eoc, 0); + if (ret) { dev_err(dev->class_dev, "timeout\n"); - return -ETIMEDOUT; + return ret; } /* read data */ From 443e6d02c8f5541f8f81b5f2b54cf5277ee5fadb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:32 -0700 Subject: [PATCH 0221/1375] staging: comedi: dyna_pci10xx: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Also, remove some unnecessary comments. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dyna_pci10xx.c | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 69157320df4e..6d03b8fe1c24 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -57,18 +57,27 @@ struct dyna_pci10xx_private { unsigned long BADR3; }; -/******************************************************************************/ -/************************** READ WRITE FUNCTIONS ******************************/ -/******************************************************************************/ +static int dyna_pci10xx_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw_p(dev->iobase); + if (status & (1 << 15)) + return 0; + return -EBUSY; +} -/* analog input callback */ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct dyna_pci10xx_private *devpriv = dev->private; - int n, counter; + int n; u16 d = 0; + int ret = 0; unsigned int chan, range; /* get the channel number and range */ @@ -82,18 +91,17 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, smp_mb(); outw_p(0x0000 + range + chan, dev->iobase + 2); udelay(10); - /* read data */ - for (counter = 0; counter < READ_TIMEOUT; counter++) { - d = inw_p(dev->iobase); - /* check if read is successful if the EOC bit is set */ - if (d & (1 << 15)) - goto conv_finish; + ret = comedi_timeout(dev, s, insn, dyna_pci10xx_ai_eoc, 0); + if (ret) { + data[n] = 0; + dev_dbg(dev->class_dev, + "timeout reading analog input\n"); + break; } - data[n] = 0; - dev_dbg(dev->class_dev, "timeout reading analog input\n"); - continue; -conv_finish: + + /* read data */ + d = inw_p(dev->iobase); /* mask the first 4 bits - EOC bits */ d &= 0x0FFF; data[n] = d; @@ -101,7 +109,7 @@ conv_finish: mutex_unlock(&devpriv->mutex); /* return the number of samples read/written */ - return n; + return ret ? ret : n; } /* analog output callback */ From e2fde58204af85f20d08e2dc97b9586d2f34497e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:33 -0700 Subject: [PATCH 0222/1375] staging: comedi: icp_multi: use comedi_timeout() Use comedi_timeout() to wait for the analog input and output end-of- conversion. Use break to exit the loop when a timeout occurs during the analog input read so that common code can be used to disable the device. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/icp_multi.c | 108 +++++++++++---------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index 19c586bae04e..7fb6ca0a2f26 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -171,12 +171,27 @@ static void setup_channel_list(struct comedi_device *dev, } } +static int icp_multi_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct icp_multi_private *devpriv = dev->private; + unsigned int status; + + status = readw(devpriv->io_addr + ICP_MULTI_ADC_CSR); + if ((status & ADC_BSY) == 0) + return 0; + return -EBUSY; +} + static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct icp_multi_private *devpriv = dev->private; - int n, timeout; + int ret = 0; + int n; /* Disable A/D conversion ready interrupt */ devpriv->IntEnable &= ~ADC_READY; @@ -199,33 +214,14 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, udelay(1); /* Wait for conversion to complete, or get fed up waiting */ - timeout = 100; - while (timeout--) { - if (!(readw(devpriv->io_addr + - ICP_MULTI_ADC_CSR) & ADC_BSY)) - goto conv_finish; - - udelay(1); + ret = comedi_timeout(dev, s, insn, icp_multi_ai_eoc, 0); + if (ret) { + comedi_error(dev, "A/D insn timeout"); + /* Clear data received */ + data[n] = 0; + break; } - /* If we reach here, a timeout has occurred */ - comedi_error(dev, "A/D insn timeout"); - - /* Disable interrupt */ - devpriv->IntEnable &= ~ADC_READY; - writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN); - - /* Clear interrupt status */ - devpriv->IntStatus |= ADC_READY; - writew(devpriv->IntStatus, - devpriv->io_addr + ICP_MULTI_INT_STAT); - - /* Clear data received */ - data[n] = 0; - - return -ETIME; - -conv_finish: data[n] = (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff; } @@ -238,7 +234,21 @@ conv_finish: devpriv->IntStatus |= ADC_READY; writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT); - return n; + return ret ? ret : n; +} + +static int icp_multi_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct icp_multi_private *devpriv = dev->private; + unsigned int status; + + status = readw(devpriv->io_addr + ICP_MULTI_DAC_CSR); + if ((status & DAC_BSY) == 0) + return 0; + return -EBUSY; } static int icp_multi_insn_write_ao(struct comedi_device *dev, @@ -246,7 +256,8 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { struct icp_multi_private *devpriv = dev->private; - int n, chan, range, timeout; + int n, chan, range; + int ret; /* Disable D/A conversion ready interrupt */ devpriv->IntEnable &= ~DAC_READY; @@ -274,33 +285,26 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { /* Wait for analogue output data register to be * ready for new data, or get fed up waiting */ - timeout = 100; - while (timeout--) { - if (!(readw(devpriv->io_addr + - ICP_MULTI_DAC_CSR) & DAC_BSY)) - goto dac_ready; + ret = comedi_timeout(dev, s, insn, icp_multi_ao_eoc, 0); + if (ret) { + comedi_error(dev, "D/A insn timeout"); - udelay(1); + /* Disable interrupt */ + devpriv->IntEnable &= ~DAC_READY; + writew(devpriv->IntEnable, + devpriv->io_addr + ICP_MULTI_INT_EN); + + /* Clear interrupt status */ + devpriv->IntStatus |= DAC_READY; + writew(devpriv->IntStatus, + devpriv->io_addr + ICP_MULTI_INT_STAT); + + /* Clear data received */ + devpriv->ao_data[chan] = 0; + + return ret; } - /* If we reach here, a timeout has occurred */ - comedi_error(dev, "D/A insn timeout"); - - /* Disable interrupt */ - devpriv->IntEnable &= ~DAC_READY; - writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN); - - /* Clear interrupt status */ - devpriv->IntStatus |= DAC_READY; - writew(devpriv->IntStatus, - devpriv->io_addr + ICP_MULTI_INT_STAT); - - /* Clear data received */ - devpriv->ao_data[chan] = 0; - - return -ETIME; - -dac_ready: /* Write data to analogue output data register */ writew(data[n], devpriv->io_addr + ICP_MULTI_AO); From f7d108f324149205eca23de5ee96d0713f9dca91 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:34 -0700 Subject: [PATCH 0223/1375] staging: comedi: multiq3: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/multiq3.c | 38 +++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 3ca755eca285..b74b9e9bfd4a 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -81,34 +81,44 @@ struct multiq3_private { unsigned int ao_readback[2]; }; +static int multiq3_ai_status(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + MULTIQ3_STATUS); + if (status & context) + return 0; + return -EBUSY; +} + static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int i, n; + int n; int chan; unsigned int hi, lo; + int ret; chan = CR_CHAN(insn->chanspec); outw(MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3), dev->iobase + MULTIQ3_CONTROL); - for (i = 0; i < MULTIQ3_TIMEOUT; i++) { - if (inw(dev->iobase + MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC) - break; - } - if (i == MULTIQ3_TIMEOUT) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, multiq3_ai_status, + MULTIQ3_STATUS_EOC); + if (ret) + return ret; for (n = 0; n < insn->n; n++) { outw(0, dev->iobase + MULTIQ3_AD_CS); - for (i = 0; i < MULTIQ3_TIMEOUT; i++) { - if (inw(dev->iobase + - MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC_I) - break; - } - if (i == MULTIQ3_TIMEOUT) - return -ETIMEDOUT; + + ret = comedi_timeout(dev, s, insn, multiq3_ai_status, + MULTIQ3_STATUS_EOC_I); + if (ret) + return ret; hi = inb(dev->iobase + MULTIQ3_AD_CS); lo = inb(dev->iobase + MULTIQ3_AD_CS); From a9f9d8314541144238f891a310a736ca8d5b107b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:35 -0700 Subject: [PATCH 0224/1375] staging: comedi: ni_daq_700: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_daq_700.c | 53 +++++++++++++-------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 7979a6610426..e56bfeb89a81 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -109,14 +109,31 @@ static int daq700_dio_insn_config(struct comedi_device *dev, return insn->n; } +static int daq700_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + STA_R2); + if ((status & 0x03)) + return -EOVERFLOW; + status = inb(dev->iobase + STA_R1); + if ((status & 0x02)) + return -ENODATA; + if ((status & 0x11) == 0x01) + return 0; + return -EBUSY; +} + static int daq700_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int n, i, chan; + int n, chan; int d; - unsigned int status; - enum { TIMEOUT = 100 }; + int ret; chan = CR_CHAN(insn->chanspec); /* write channel to multiplexer */ @@ -130,30 +147,26 @@ static int daq700_ai_rinsn(struct comedi_device *dev, outb(0x30, dev->iobase + CMO_R); /* mode 0 out0 L, from H */ /* mode 1 out0 H, L to H, start conversion */ outb(0x32, dev->iobase + CMO_R); + /* wait for conversion to end */ - for (i = 0; i < TIMEOUT; i++) { - status = inb(dev->iobase + STA_R2); - if ((status & 0x03) != 0) { + ret = comedi_timeout(dev, s, insn, daq700_ai_eoc, 0); + if (ret) { + switch (ret) { + case -EOVERFLOW: dev_info(dev->class_dev, "Overflow/run Error\n"); - return -EOVERFLOW; - } - status = inb(dev->iobase + STA_R1); - if ((status & 0x02) != 0) { + break; + case -ENODATA: dev_info(dev->class_dev, "Data Error\n"); - return -ENODATA; - } - if ((status & 0x11) == 0x01) { - /* ADC conversion complete */ + break; + default: + dev_info(dev->class_dev, + "timeout during ADC conversion\n"); break; } - udelay(1); - } - if (i == TIMEOUT) { - dev_info(dev->class_dev, - "timeout during ADC conversion\n"); - return -ETIMEDOUT; + return ret; } + /* read data */ d = inw(dev->iobase + ADFIFO_R); /* mangle the data as necessary */ From 051448c5257d5645db0edd70b43cc27485f133fa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:36 -0700 Subject: [PATCH 0225/1375] staging: comedi: rtd520: use comedi_timeout() Use comedi_timeout() to wait for the analog input and output end-of- conversions. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 84 +++++++++++-------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 0e83e7e80b49..cd3fdf973bdd 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -237,20 +237,6 @@ /* The board support a channel list up to the FIFO length (1K or 8K) */ #define RTD_MAX_CHANLIST 128 /* max channel list that we allow */ -/* tuning for ai/ao instruction done polling */ -#ifdef FAST_SPIN -#define WAIT_QUIETLY /* as nothing, spin on done bit */ -#define RTD_ADC_TIMEOUT 66000 /* 2 msec at 33mhz bus rate */ -#define RTD_DAC_TIMEOUT 66000 -#define RTD_DMA_TIMEOUT 33000 /* 1 msec */ -#else -/* by delaying, power and electrical noise are reduced somewhat */ -#define WAIT_QUIETLY udelay(1) -#define RTD_ADC_TIMEOUT 2000 /* in usec */ -#define RTD_DAC_TIMEOUT 2000 /* in usec */ -#define RTD_DMA_TIMEOUT 1000 /* in usec */ -#endif - /*====================================================================== Board specific stuff ======================================================================*/ @@ -562,21 +548,27 @@ static int rtd520_probe_fifo_depth(struct comedi_device *dev) return fifo_size; } -/* - "instructions" read/write data in "one-shot" or "software-triggered" - mode (simplest case). - This doesn't use interrupts. +static int rtd_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct rtd_private *devpriv = dev->private; + unsigned int status; + + status = readl(devpriv->las0 + LAS0_ADC); + if (status & FS_ADC_NOT_EMPTY) + return 0; + return -EBUSY; +} - Note, we don't do any settling delays. Use a instruction list to - select, delay, then read. - */ static int rtd_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct rtd_private *devpriv = dev->private; - int n, ii; - int stat; + int ret; + int n; /* clear any old fifo data */ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR); @@ -593,14 +585,9 @@ static int rtd_ai_rinsn(struct comedi_device *dev, /* trigger conversion */ writew(0, devpriv->las0 + LAS0_ADC); - for (ii = 0; ii < RTD_ADC_TIMEOUT; ++ii) { - stat = readl(devpriv->las0 + LAS0_ADC); - if (stat & FS_ADC_NOT_EMPTY) /* 1 -> not empty */ - break; - WAIT_QUIETLY; - } - if (ii >= RTD_ADC_TIMEOUT) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, rtd_ai_eoc, 0); + if (ret) + return ret; /* read data */ d = readw(devpriv->las1 + LAS1_ADC_FIFO); @@ -1116,9 +1103,22 @@ static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -/* - Output one (or more) analog values to a single port as fast as possible. -*/ +static int rtd_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct rtd_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int bit = (chan == 0) ? FS_DAC1_NOT_EMPTY : FS_DAC2_NOT_EMPTY; + unsigned int status; + + status = readl(devpriv->las0 + LAS0_ADC); + if (status & bit) + return 0; + return -EBUSY; +} + static int rtd_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -1127,6 +1127,7 @@ static int rtd_ao_winsn(struct comedi_device *dev, int i; int chan = CR_CHAN(insn->chanspec); int range = CR_RANGE(insn->chanspec); + int ret; /* Configure the output range (table index matches the range values) */ writew(range & 7, devpriv->las0 + @@ -1136,8 +1137,6 @@ static int rtd_ao_winsn(struct comedi_device *dev, * very useful, but that's how the interface is defined. */ for (i = 0; i < insn->n; ++i) { int val = data[i] << 3; - int stat = 0; /* initialize to avoid bogus warning */ - int ii; /* VERIFY: comedi range and offset conversions */ @@ -1157,16 +1156,9 @@ static int rtd_ao_winsn(struct comedi_device *dev, devpriv->ao_readback[chan] = data[i]; - for (ii = 0; ii < RTD_DAC_TIMEOUT; ++ii) { - stat = readl(devpriv->las0 + LAS0_ADC); - /* 1 -> not empty */ - if (stat & ((0 == chan) ? FS_DAC1_NOT_EMPTY : - FS_DAC2_NOT_EMPTY)) - break; - WAIT_QUIETLY; - } - if (ii >= RTD_DAC_TIMEOUT) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, rtd_ao_eoc, 0); + if (ret) + return ret; } /* return the number of samples read/written */ From 45b281e457dc5e80650ca6808fb08df49b677f03 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:37 -0700 Subject: [PATCH 0226/1375] staging: comedi: s626: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. This prevents a deadlock condition that could occur by providing a timeout in case the end-of-conversion does not happen. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 9e711ee13bb7..5ba4b4ae6507 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1846,6 +1846,20 @@ static int s626_ai_rinsn(struct comedi_device *dev, } #endif +static int s626_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct s626_private *devpriv = dev->private; + unsigned int status; + + status = readl(devpriv->mmio + S626_P_PSR); + if (status & S626_PSR_GPIO2) + return 0; + return -EBUSY; +} + static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -1856,6 +1870,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, uint16_t adc_spec = 0; uint32_t gpio_image; uint32_t tmp; + int ret; int n; /* @@ -1897,8 +1912,9 @@ static int s626_ai_insn_read(struct comedi_device *dev, */ /* Wait for ADC done */ - while (!(readl(devpriv->mmio + S626_P_PSR) & S626_PSR_GPIO2)) - ; + ret = comedi_timeout(dev, s, insn, s626_ai_eoc, 0); + if (ret) + return ret; /* Fetch ADC data */ if (n != 0) { From d8644e418b2613b3eaf1e10fe6fd0d84018c2f8a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:38 -0700 Subject: [PATCH 0227/1375] staging: comedi: dt282x: use comedi_timeout() The wait_for() macro in this driver is a bit nasty. It effects control flow which according to the CodingStyle is a _very_ bad idea. The mux_busy() and ad_done() macros are also bad since they rely on a local variable having a specific name. Remove these macros and use comedi_timeout() to wait for the analog input mux busy completion and end-of-conversion. Both of these are detected by reading the same register and testing different bits. Pass the bits to test as the 'context' to the callback function. The dt282x_ai_cmd() function also checks for the mux busy completion. The 'insn' is not available here but passing NULL is safe because nothing uses it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 68 +++++++++++++++---------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 895f73a19023..f768210184c1 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -63,7 +63,6 @@ Notes: #include "comedi_fc.h" -#define DT2821_TIMEOUT 100 /* 500 us */ #define DT2821_SIZE 0x10 /* @@ -248,27 +247,6 @@ struct dt282x_private { * Some useless abstractions */ #define chan_to_DAC(a) ((a)&1) -#define mux_busy() (inw(dev->iobase+DT2821_ADCSR)&DT2821_MUXBUSY) -#define ad_done() (inw(dev->iobase+DT2821_ADCSR)&DT2821_ADDONE) - -/* - * danger! macro abuse... a is the expression to wait on, and b is - * the statement(s) to execute if it doesn't happen. - */ -#define wait_for(a, b) \ - do { \ - int _i; \ - for (_i = 0; _i < DT2821_TIMEOUT; _i++) { \ - if (a) { \ - _i = 0; \ - break; \ - } \ - udelay(5); \ - } \ - if (_i) { \ - b \ - } \ - } while (0) static int prep_ai_dma(struct comedi_device *dev, int chan, int size); static int prep_ao_dma(struct comedi_device *dev, int chan, int size); @@ -530,6 +508,29 @@ static void dt282x_load_changain(struct comedi_device *dev, int n, outw(n - 1, dev->iobase + DT2821_CHANCSR); } +static int dt282x_ai_timeout(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + DT2821_ADCSR); + switch (context) { + case DT2821_MUXBUSY: + if ((status & DT2821_MUXBUSY) == 0) + return 0; + break; + case DT2821_ADDONE: + if (status & DT2821_ADDONE) + return 0; + break; + default: + return -EINVAL; + } + return -EBUSY; +} + /* * Performs a single A/D conversion. * - Put channel/gain into channel-gain list @@ -542,6 +543,7 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, { const struct dt282x_board *board = comedi_board(dev); struct dt282x_private *devpriv = dev->private; + int ret; int i; /* XXX should we really be enabling the ad clock here? */ @@ -551,13 +553,22 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, dt282x_load_changain(dev, 1, &insn->chanspec); outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR); - wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;); + ret = comedi_timeout(dev, s, insn, dt282x_ai_timeout, DT2821_MUXBUSY); + if (ret) { + comedi_error(dev, "timeout\n"); + return ret; + } for (i = 0; i < insn->n; i++) { outw(devpriv->supcsr | DT2821_STRIG, dev->iobase + DT2821_SUPCSR); - wait_for(ad_done(), comedi_error(dev, "timeout\n"); - return -ETIME;); + + ret = comedi_timeout(dev, s, insn, dt282x_ai_timeout, + DT2821_ADDONE); + if (ret) { + comedi_error(dev, "timeout\n"); + return ret; + } data[i] = inw(dev->iobase + @@ -646,6 +657,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct dt282x_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; int timer; + int ret; if (devpriv->usedma == 0) { comedi_error(dev, @@ -691,7 +703,11 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR); outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR); - wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;); + ret = comedi_timeout(dev, s, NULL, dt282x_ai_timeout, DT2821_MUXBUSY); + if (ret) { + comedi_error(dev, "timeout\n"); + return ret; + } if (cmd->scan_begin_src == TRIG_FOLLOW) { outw(devpriv->supcsr | DT2821_STRIG, From 304d2e4cc018cf90811821e8ff3e6d6242d0ece5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:39 -0700 Subject: [PATCH 0228/1375] staging: comedi: daqboard2000: use comedi_timeout() Use comedi_timeout() to wait for the analog input pipe full, scanning, amd end-of-conversion status. The status to check it passed as the 'context' to comedi_timeout(). Use comedi_timeout() to wait for the analog output end-of-conversion. This also fixes a possible bug where invalid data is returned for the analog input read if the conversion did not complete, The analog output has a similar possible bug where the cached readback value is incorrect if the conversion times out. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 82 ++++++++++++------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 6ff7d3e1971a..a8f6036ad82b 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -333,14 +333,28 @@ static void setup_sampling(struct comedi_device *dev, int chan, int gain) writeAcqScanListEntry(dev, word3); } +static int daqboard2000_ai_status(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct daqboard2000_private *devpriv = dev->private; + unsigned int status; + + status = readw(devpriv->daq + acqControl); + if (status & context) + return 0; + return -EBUSY; +} + static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct daqboard2000_private *devpriv = dev->private; - unsigned int val; - int gain, chan, timeout; + int gain, chan; + int ret; int i; writew(DAQBOARD2000_AcqResetScanListFifo | @@ -367,25 +381,24 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, /* Enable reading from the scanlist FIFO */ writew(DAQBOARD2000_SeqStartScanList, devpriv->daq + acqControl); - for (timeout = 0; timeout < 20; timeout++) { - val = readw(devpriv->daq + acqControl); - if (val & DAQBOARD2000_AcqConfigPipeFull) - break; - /* udelay(2); */ - } + + ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, + DAQBOARD2000_AcqConfigPipeFull); + if (ret) + return ret; + writew(DAQBOARD2000_AdcPacerEnable, devpriv->daq + acqControl); - for (timeout = 0; timeout < 20; timeout++) { - val = readw(devpriv->daq + acqControl); - if (val & DAQBOARD2000_AcqLogicScanning) - break; - /* udelay(2); */ - } - for (timeout = 0; timeout < 20; timeout++) { - val = readw(devpriv->daq + acqControl); - if (val & DAQBOARD2000_AcqResultsFIFOHasValidData) - break; - /* udelay(2); */ - } + + ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, + DAQBOARD2000_AcqLogicScanning); + if (ret) + return ret; + + ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, + DAQBOARD2000_AcqResultsFIFOHasValidData); + if (ret) + return ret; + data[i] = readw(devpriv->daq + acqResultsFIFO); writew(DAQBOARD2000_AdcPacerDisable, devpriv->daq + acqControl); writew(DAQBOARD2000_SeqStopScanList, devpriv->daq + acqControl); @@ -409,6 +422,21 @@ static int daqboard2000_ao_insn_read(struct comedi_device *dev, return i; } +static int daqboard2000_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct daqboard2000_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int status; + + status = readw(devpriv->daq + dacControl); + if ((status & ((chan + 1) * 0x0010)) == 0) + return 0; + return -EBUSY; +} + static int daqboard2000_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -416,8 +444,7 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, { struct daqboard2000_private *devpriv = dev->private; int chan = CR_CHAN(insn->chanspec); - unsigned int val; - int timeout; + int ret; int i; for (i = 0; i < insn->n; i++) { @@ -431,12 +458,11 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, udelay(1000); #endif writew(data[i], devpriv->daq + dacSetting(chan)); - for (timeout = 0; timeout < 20; timeout++) { - val = readw(devpriv->daq + dacControl); - if ((val & ((chan + 1) * 0x0010)) == 0) - break; - /* udelay(2); */ - } + + ret = comedi_timeout(dev, s, insn, daqboard2000_ao_eoc, 0); + if (ret) + return ret; + devpriv->ao_readback[chan] = data[i]; #if 0 /* From 625791ec760460e1dc6fa3f3a213573d86ce108f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:40 -0700 Subject: [PATCH 0229/1375] staging: comedi: pcl812: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Combine the logic for the pcl812 and acl812 end-of-conversion in the helper function to simplify the driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 72 ++++++++++++++----------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 53613b385f35..2ad6c73dfd68 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -394,16 +394,35 @@ static void setup_range_channel(struct comedi_device *dev, unsigned int rangechan, char wait); static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -/* -============================================================================== -*/ + +static int pcl812_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct pcl812_private *devpriv = dev->private; + unsigned int status; + + if (devpriv->ai_is16b) { + status = inb(dev->iobase + ACL8216_STATUS); + if ((status & ACL8216_DRDY) == 0) + return 0; + } else { + status = inb(dev->iobase + PCL812_AD_HI); + if ((status & PCL812_DRDY) == 0) + return 0; + } + return -EBUSY; +} + static int pcl812_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct pcl812_private *devpriv = dev->private; + int ret = 0; int n; - int timeout, hi; + int hi; /* select software trigger */ outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE); @@ -413,33 +432,27 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, /* start conversion */ outb(255, dev->iobase + PCL812_SOFTTRIG); udelay(5); - timeout = 50; /* wait max 50us, it must finish under 33us */ - while (timeout--) { - hi = inb(dev->iobase + PCL812_AD_HI); - if (!(hi & PCL812_DRDY)) - goto conv_finish; - udelay(1); - } - dev_dbg(dev->class_dev, "A/D insn read timeout\n"); - outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); - return -ETIME; -conv_finish: + ret = comedi_timeout(dev, s, insn, pcl812_ai_eoc, 0); + if (ret) { + dev_dbg(dev->class_dev, "A/D insn read timeout\n"); + break; + } + + hi = inb(dev->iobase + PCL812_AD_HI); data[n] = ((hi & 0xf) << 8) | inb(dev->iobase + PCL812_AD_LO); } outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); - return n; + + return ret ? ret : n; } -/* -============================================================================== -*/ static int acl8216_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { + int ret = 0; int n; - int timeout; /* select software trigger */ outb(1, dev->iobase + PCL812_MODE); @@ -449,23 +462,20 @@ static int acl8216_ai_insn_read(struct comedi_device *dev, /* start conversion */ outb(255, dev->iobase + PCL812_SOFTTRIG); udelay(5); - timeout = 50; /* wait max 50us, it must finish under 33us */ - while (timeout--) { - if (!(inb(dev->iobase + ACL8216_STATUS) & ACL8216_DRDY)) - goto conv_finish; - udelay(1); - } - dev_dbg(dev->class_dev, "A/D insn read timeout\n"); - outb(0, dev->iobase + PCL812_MODE); - return -ETIME; -conv_finish: + ret = comedi_timeout(dev, s, insn, pcl812_ai_eoc, 0); + if (ret) { + dev_dbg(dev->class_dev, "A/D insn read timeout\n"); + break; + } + data[n] = (inb(dev->iobase + PCL812_AD_HI) << 8) | inb(dev->iobase + PCL812_AD_LO); } outb(0, dev->iobase + PCL812_MODE); - return n; + + return ret ? ret : n; } /* From c0c3531b59c9ef27760c941b0206a6074699d3b6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:41 -0700 Subject: [PATCH 0230/1375] staging: comedi: pcl816: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 45 ++++++++++++------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index e9d470459933..db00d079c9c9 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -160,16 +160,25 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd); static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); -/* -============================================================================== - ANALOG INPUT MODE0, 816 cards, slow version -*/ +static int pcl816_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + PCL816_STATUS); + if ((status & PCL816_STATUS_DRDY_MASK) == 0) + return 0; + return -EBUSY; +} + static int pcl816_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { + int ret; int n; - int timeout; /* software trigger, DMA and INT off */ outb(0, dev->iobase + PCL816_CONTROL); @@ -185,30 +194,20 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, outb(0, dev->iobase + PCL816_AD_LO); /* start conversion */ - timeout = 100; - while (timeout--) { - if (!(inb(dev->iobase + PCL816_STATUS) & - PCL816_STATUS_DRDY_MASK)) { - /* return read value */ - data[n] = - ((inb(dev->iobase + - PCL816_AD_HI) << 8) | - (inb(dev->iobase + PCL816_AD_LO))); - /* clear INT (conversion end) flag */ - outb(0, dev->iobase + PCL816_CLRINT); - break; - } - udelay(1); - } - /* Return timeout error */ - if (!timeout) { + ret = comedi_timeout(dev, s, insn, pcl816_ai_eoc, 0); + if (ret) { comedi_error(dev, "A/D insn timeout\n"); data[0] = 0; /* clear INT (conversion end) flag */ outb(0, dev->iobase + PCL816_CLRINT); - return -EIO; + return ret; } + /* return read value */ + data[n] = ((inb(dev->iobase + PCL816_AD_HI) << 8) | + (inb(dev->iobase + PCL816_AD_LO))); + /* clear INT (conversion end) flag */ + outb(0, dev->iobase + PCL816_CLRINT); } return n; } From 1d6f4af9090021eb7a1074d30ebd991d43a639c6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:42 -0700 Subject: [PATCH 0231/1375] staging: comedi: pcl818: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 35 ++++++++++++++----------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index fa1758ad49d5..ff5cc1b8bed7 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -336,16 +336,25 @@ static int pcl818_ai_cancel(struct comedi_device *dev, static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); -/* -============================================================================== - ANALOG INPUT MODE0, 818 cards, slow version -*/ +static int pcl818_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + PCL818_STATUS); + if (status & 0x10) + return 0; + return -EBUSY; +} + static int pcl818_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { + int ret; int n; - int timeout; /* software trigger, DMA and INT off */ outb(0, dev->iobase + PCL818_CONTROL); @@ -364,18 +373,14 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, /* start conversion */ outb(0, dev->iobase + PCL818_AD_LO); - timeout = 100; - while (timeout--) { - if (inb(dev->iobase + PCL818_STATUS) & 0x10) - goto conv_finish; - udelay(1); + ret = comedi_timeout(dev, s, insn, pcl818_ai_eoc, 0); + if (ret) { + comedi_error(dev, "A/D insn timeout"); + /* clear INT (conversion end) flag */ + outb(0, dev->iobase + PCL818_CLRINT); + return ret; } - comedi_error(dev, "A/D insn timeout"); - /* clear INT (conversion end) flag */ - outb(0, dev->iobase + PCL818_CLRINT); - return -EIO; -conv_finish: data[n] = ((inb(dev->iobase + PCL818_AD_HI) << 4) | (inb(dev->iobase + PCL818_AD_LO) >> 4)); } From 82c7e864a0fe0a2eb381f678e34909595eac9be8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:43 -0700 Subject: [PATCH 0232/1375] staging: comedi: dt2814: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2814.c | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index abad6e49c1c1..3794b7e52091 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -66,26 +66,35 @@ struct dt2814_private { #define DT2814_TIMEOUT 10 #define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */ +static int dt2814_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + DT2814_CSR); + if (status & DT2814_FINISH) + return 0; + return -EBUSY; +} + static int dt2814_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int n, i, hi, lo; + int n, hi, lo; int chan; - int status = 0; + int ret; for (n = 0; n < insn->n; n++) { chan = CR_CHAN(insn->chanspec); outb(chan, dev->iobase + DT2814_CSR); - for (i = 0; i < DT2814_TIMEOUT; i++) { - status = inb(dev->iobase + DT2814_CSR); - udelay(10); - if (status & DT2814_FINISH) - break; - } - if (i >= DT2814_TIMEOUT) - return -ETIMEDOUT; + + ret = comedi_timeout(dev, s, insn, dt2814_ai_eoc, 0); + if (ret) + return ret; hi = inb(dev->iobase + DT2814_DATA); lo = inb(dev->iobase + DT2814_DATA); From f7b3d79a622c97483c8d0e6e4bbd5207929259d9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:44 -0700 Subject: [PATCH 0233/1375] staging: comedi: dmm32at: use comedi_timeout() Use comedi_timeout() to wait for the analog input settle and end-of- conversion. These tests use different registers but the same bit so the register is passed as the 'context'. The same test is used in dmm32at_ai_cmd() but the 'insn' is not available. This is ok since the test function, and comedi_timeout() don't use it. Use comedi_timout() to wait for the analog output end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 83 ++++++++++++++---------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 78a19629ff56..c8a36eb5f015 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -164,16 +164,29 @@ struct dmm32at_private { }; +static int dmm32at_ai_status(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned char status; + + status = inb(dev->iobase + context); + if ((status & DMM32AT_STATUS) == 0) + return 0; + return -EBUSY; +} + static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int n, i; + int n; unsigned int d; - unsigned char status; unsigned short msb, lsb; unsigned char chan; int range; + int ret; /* get the channel and range number */ @@ -190,26 +203,20 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev, outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); /* wait for circuit to settle */ - for (i = 0; i < 40000; i++) { - status = inb(dev->iobase + DMM32AT_AIRBACK); - if ((status & DMM32AT_STATUS) == 0) - break; - } - if (i == 40000) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, DMM32AT_AIRBACK); + if (ret) + return ret; /* convert n samples */ for (n = 0; n < insn->n; n++) { /* trigger conversion */ outb(0xff, dev->iobase + DMM32AT_CONV); + /* wait for conversion to end */ - for (i = 0; i < 40000; i++) { - status = inb(dev->iobase + DMM32AT_AISTAT); - if ((status & DMM32AT_STATUS) == 0) - break; - } - if (i == 40000) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, + DMM32AT_AISTAT); + if (ret) + return ret; /* read data */ lsb = inb(dev->iobase + DMM32AT_AILSB); @@ -403,8 +410,9 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct dmm32at_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int i, range; - unsigned char chanlo, chanhi, status; + int range; + unsigned char chanlo, chanhi; + int ret; if (!cmd->chanlist) return -EINVAL; @@ -439,14 +447,13 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * isr */ } - /* wait for circuit to settle */ - for (i = 0; i < 40000; i++) { - status = inb(dev->iobase + DMM32AT_AIRBACK); - if ((status & DMM32AT_STATUS) == 0) - break; - } - if (i == 40000) - return -ETIMEDOUT; + /* + * wait for circuit to settle + * we don't have the 'insn' here but it's not needed + */ + ret = comedi_timeout(dev, s, NULL, dmm32at_ai_status, DMM32AT_AIRBACK); + if (ret) + return ret; if (devpriv->ai_scans_left > 1) { /* start the clock and enable the interrupts */ @@ -525,6 +532,19 @@ static irqreturn_t dmm32at_isr(int irq, void *d) return IRQ_HANDLED; } +static int dmm32at_ao_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned char status; + + status = inb(dev->iobase + DMM32AT_DACSTAT); + if ((status & DMM32AT_DACBUSY) == 0) + return 0; + return -EBUSY; +} + static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -533,6 +553,7 @@ static int dmm32at_ao_winsn(struct comedi_device *dev, int i; int chan = CR_CHAN(insn->chanspec); unsigned char hi, lo, status; + int ret; /* Writing a list of values to an AO channel is probably not * very useful, but that's how the interface is defined. */ @@ -549,13 +570,9 @@ static int dmm32at_ao_winsn(struct comedi_device *dev, outb(hi, dev->iobase + DMM32AT_DACMSB); /* wait for circuit to settle */ - for (i = 0; i < 40000; i++) { - status = inb(dev->iobase + DMM32AT_DACSTAT); - if ((status & DMM32AT_DACBUSY) == 0) - break; - } - if (i == 40000) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, dmm32at_ao_eoc, 0); + if (ret) + return ret; /* dummy read to update trigger the output */ status = inb(dev->iobase + DMM32AT_DACMSB); From 22ca19d93d92c79cff68270846a84bd34fe6fb34 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:45 -0700 Subject: [PATCH 0234/1375] staging: comedi: move (*insn_{read, write}) timeout debug messages to core Have the comedi core display a standard dev_dbg() message when a timeout occurs and remove all the driver specific messages. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 13 ++++++++++++- drivers/staging/comedi/drivers/adl_pci9111.c | 1 - drivers/staging/comedi/drivers/adl_pci9118.c | 1 - drivers/staging/comedi/drivers/adv_pci1710.c | 1 - drivers/staging/comedi/drivers/aio_aio12_8.c | 4 +--- drivers/staging/comedi/drivers/amplc_pci230.c | 4 +--- drivers/staging/comedi/drivers/cb_das16_cs.c | 4 +--- drivers/staging/comedi/drivers/cb_pcidas64.c | 4 +--- drivers/staging/comedi/drivers/das08.c | 4 +--- drivers/staging/comedi/drivers/das16m1.c | 4 +--- drivers/staging/comedi/drivers/dt2815.c | 12 ++---------- drivers/staging/comedi/drivers/dt282x.c | 12 +++--------- drivers/staging/comedi/drivers/dyna_pci10xx.c | 2 -- drivers/staging/comedi/drivers/icp_multi.c | 3 --- drivers/staging/comedi/drivers/me_daq.c | 4 +--- drivers/staging/comedi/drivers/ni_at_a2150.c | 8 ++------ drivers/staging/comedi/drivers/ni_daq_700.c | 16 +--------------- drivers/staging/comedi/drivers/pcl812.c | 8 ++------ drivers/staging/comedi/drivers/pcl816.c | 1 - drivers/staging/comedi/drivers/pcl818.c | 1 - drivers/staging/comedi/drivers/skel.c | 4 +--- 21 files changed, 30 insertions(+), 81 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index b36b76060d03..ac1edd9d1e21 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1194,6 +1194,11 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, switch (insn->insn) { case INSN_READ: ret = s->insn_read(dev, s, insn, data); + if (ret == -ETIMEDOUT) { + dev_dbg(dev->class_dev, + "subdevice %d read instruction timed out\n", + s->index); + } break; case INSN_WRITE: maxdata = s->maxdata_list @@ -1207,8 +1212,14 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, break; } } - if (ret == 0) + if (ret == 0) { ret = s->insn_write(dev, s, insn, data); + if (ret == -ETIMEDOUT) { + dev_dbg(dev->class_dev, + "subdevice %d write instruction timed out\n", + s->index); + } + } break; case INSN_BITS: if (insn->n != 2) { diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index c741e8a04146..647b2d814d61 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -748,7 +748,6 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pci9111_ai_eoc, 0); if (ret) { - comedi_error(dev, "A/D read timeout"); data[i] = 0; pci9111_fifo_reset(dev); return ret; diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 6492bd81efe8..9218e9293cf5 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -614,7 +614,6 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pci9118_ai_eoc, 0); if (ret) { - comedi_error(dev, "A/D insn timeout"); data[n] = 0; outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return ret; diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 36ed579cdd95..16c4bb00022c 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -467,7 +467,6 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pci171x_ai_eoc, 0); if (ret) { - comedi_error(dev, "A/D insn timeout"); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); data[n] = 0; diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 3f994ed3db42..324746b14931 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -140,10 +140,8 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, /* Wait for conversion to complete */ ret = comedi_timeout(dev, s, insn, aio_aio12_8_ai_eoc, 0); - if (ret) { - dev_err(dev->class_dev, "ADC timeout\n"); + if (ret) return ret; - } data[n] = inw(dev->iobase + AIO12_8_ADC_REG) & s->maxdata; } diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index b606bdb2826e..99e60835dc4a 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -895,10 +895,8 @@ static int pci230_ai_rinsn(struct comedi_device *dev, /* wait for conversion to end */ ret = comedi_timeout(dev, s, insn, pci230_ai_eoc, 0); - if (ret) { - dev_err(dev->class_dev, "timeout\n"); + if (ret) return ret; - } /* read data */ data[n] = pci230_ai_read(dev); diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 549844cf2b35..e0ed193522e0 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -152,10 +152,8 @@ static int das16cs_ai_rinsn(struct comedi_device *dev, outw(0, dev->iobase + DAS16CS_ADC_DATA); ret = comedi_timeout(dev, s, insn, das16cs_ai_eoc, 0); - if (ret) { - dev_dbg(dev->class_dev, "cb_das16_cs: ai timeout\n"); + if (ret) return ret; - } data[i] = inw(dev->iobase + DAS16CS_ADC_DATA); } diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 21e13a5cea11..f9afcbe1da54 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1792,10 +1792,8 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* wait for data */ ret = comedi_timeout(dev, s, insn, cb_pcidas64_ai_eoc, 0); - if (ret) { - comedi_error(dev, " analog input read insn timed out"); + if (ret) return ret; - } if (thisboard->layout == LAYOUT_4020) data[n] = readl(devpriv->dio_counter_iobase + diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b9916315adc6..c5e352fb5555 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -257,10 +257,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, outb_p(0, dev->iobase + DAS08_TRIG_12BIT); ret = comedi_timeout(dev, s, insn, das08_ai_eoc, 0); - if (ret) { - dev_err(dev->class_dev, "timeout\n"); + if (ret) return ret; - } msb = inb(dev->iobase + DAS08_MSB); lsb = inb(dev->iobase + DAS08_LSB); diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index a94b7a4e495e..0a90ab341758 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -370,10 +370,8 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, outb(0, dev->iobase); ret = comedi_timeout(dev, s, insn, das16m1_ai_eoc, 0); - if (ret) { - comedi_error(dev, "timeout"); + if (ret) return ret; - } data[n] = munge_sample(inw(dev->iobase)); } diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index 1ab1dd76dfd7..b9ac4ed8babb 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -108,22 +108,14 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, hi = (data[i] & 0xff0) >> 4; ret = comedi_timeout(dev, s, insn, dt2815_ao_status, 0x00); - if (ret) { - dev_dbg(dev->class_dev, - "failed to write low byte on %d\n", - chan); + if (ret) return ret; - } outb(lo, dev->iobase + DT2815_DATA); ret = comedi_timeout(dev, s, insn, dt2815_ao_status, 0x10); - if (ret) { - dev_dbg(dev->class_dev, - "failed to write high byte on %d\n", - chan); + if (ret) return ret; - } devpriv->ao_readback[chan] = data[i]; } diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index f768210184c1..6cc8f1d5b831 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -554,10 +554,8 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR); ret = comedi_timeout(dev, s, insn, dt282x_ai_timeout, DT2821_MUXBUSY); - if (ret) { - comedi_error(dev, "timeout\n"); + if (ret) return ret; - } for (i = 0; i < insn->n; i++) { outw(devpriv->supcsr | DT2821_STRIG, @@ -565,10 +563,8 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, dt282x_ai_timeout, DT2821_ADDONE); - if (ret) { - comedi_error(dev, "timeout\n"); + if (ret) return ret; - } data[i] = inw(dev->iobase + @@ -704,10 +700,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR); ret = comedi_timeout(dev, s, NULL, dt282x_ai_timeout, DT2821_MUXBUSY); - if (ret) { - comedi_error(dev, "timeout\n"); + if (ret) return ret; - } if (cmd->scan_begin_src == TRIG_FOLLOW) { outw(devpriv->supcsr | DT2821_STRIG, diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 6d03b8fe1c24..78d44a9c8a71 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -95,8 +95,6 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, dyna_pci10xx_ai_eoc, 0); if (ret) { data[n] = 0; - dev_dbg(dev->class_dev, - "timeout reading analog input\n"); break; } diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index 7fb6ca0a2f26..ee30f2b8a54b 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -216,7 +216,6 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, /* Wait for conversion to complete, or get fed up waiting */ ret = comedi_timeout(dev, s, insn, icp_multi_ai_eoc, 0); if (ret) { - comedi_error(dev, "A/D insn timeout"); /* Clear data received */ data[n] = 0; break; @@ -287,8 +286,6 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, * ready for new data, or get fed up waiting */ ret = comedi_timeout(dev, s, insn, icp_multi_ao_eoc, 0); if (ret) { - comedi_error(dev, "D/A insn timeout"); - /* Disable interrupt */ devpriv->IntEnable &= ~DAC_READY; writew(devpriv->IntEnable, diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 288fb21b6f65..0ff126b1fdfd 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -305,10 +305,8 @@ static int me_ai_insn_read(struct comedi_device *dev, /* wait for ADC fifo not empty flag */ ret = comedi_timeout(dev, s, insn, me_ai_eoc, 0); - if (ret) { - dev_err(dev->class_dev, "Cannot get single value\n"); + if (ret) return ret; - } /* get value from ADC fifo */ val = readw(dev_private->me_regbase + ME_READ_AD_FIFO); diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 07239c967f9d..740f14994f97 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -538,10 +538,8 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, */ for (n = 0; n < 36; n++) { ret = comedi_timeout(dev, s, insn, a2150_ai_eoc, 0); - if (ret) { - comedi_error(dev, "timeout"); + if (ret) return ret; - } inw(dev->iobase + FIFO_DATA_REG); } @@ -549,10 +547,8 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* read data */ for (n = 0; n < insn->n; n++) { ret = comedi_timeout(dev, s, insn, a2150_ai_eoc, 0); - if (ret) { - comedi_error(dev, "timeout"); + if (ret) return ret; - } data[n] = inw(dev->iobase + FIFO_DATA_REG); data[n] ^= 0x8000; diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index e56bfeb89a81..171a71d20c88 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -150,22 +150,8 @@ static int daq700_ai_rinsn(struct comedi_device *dev, /* wait for conversion to end */ ret = comedi_timeout(dev, s, insn, daq700_ai_eoc, 0); - if (ret) { - switch (ret) { - case -EOVERFLOW: - dev_info(dev->class_dev, - "Overflow/run Error\n"); - break; - case -ENODATA: - dev_info(dev->class_dev, "Data Error\n"); - break; - default: - dev_info(dev->class_dev, - "timeout during ADC conversion\n"); - break; - } + if (ret) return ret; - } /* read data */ d = inw(dev->iobase + ADFIFO_R); diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 2ad6c73dfd68..feb9e98524aa 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -434,10 +434,8 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, udelay(5); ret = comedi_timeout(dev, s, insn, pcl812_ai_eoc, 0); - if (ret) { - dev_dbg(dev->class_dev, "A/D insn read timeout\n"); + if (ret) break; - } hi = inb(dev->iobase + PCL812_AD_HI); data[n] = ((hi & 0xf) << 8) | inb(dev->iobase + PCL812_AD_LO); @@ -464,10 +462,8 @@ static int acl8216_ai_insn_read(struct comedi_device *dev, udelay(5); ret = comedi_timeout(dev, s, insn, pcl812_ai_eoc, 0); - if (ret) { - dev_dbg(dev->class_dev, "A/D insn read timeout\n"); + if (ret) break; - } data[n] = (inb(dev->iobase + diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index db00d079c9c9..4bf2efb2c027 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -196,7 +196,6 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pcl816_ai_eoc, 0); if (ret) { - comedi_error(dev, "A/D insn timeout\n"); data[0] = 0; /* clear INT (conversion end) flag */ outb(0, dev->iobase + PCL816_CLRINT); diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index ff5cc1b8bed7..9087e54537ec 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -375,7 +375,6 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pcl818_ai_eoc, 0); if (ret) { - comedi_error(dev, "A/D insn timeout"); /* clear INT (conversion end) flag */ outb(0, dev->iobase + PCL818_CLRINT); return ret; diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index a4933683a575..39008cf30ecb 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -190,10 +190,8 @@ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* wait for conversion to end */ ret = comedi_timeout(dev, s, insn, skel_ai_eoc, 0); - if (ret) { - dev_warn(dev->class_dev, "ai timeout\n"); + if (ret) return ret; - } /* read data */ /* d = inw(dev->iobase + SKEL_AI_DATA); */ From dbd446fc7aab519c213e63eefa15c82586a50989 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:46 -0700 Subject: [PATCH 0235/1375] staging: comedi: don't clear 'data' on (*insn_read) timeout It's not necessary to clear the returned data pointer when an (*insn_read) times out. For aesthetics, remove all of these in the drivers. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 1 - drivers/staging/comedi/drivers/adl_pci9118.c | 1 - drivers/staging/comedi/drivers/adv_pci1710.c | 1 - drivers/staging/comedi/drivers/dyna_pci10xx.c | 4 +--- drivers/staging/comedi/drivers/icp_multi.c | 5 +---- drivers/staging/comedi/drivers/pcl816.c | 1 - 6 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 647b2d814d61..ff086d0eedd9 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -748,7 +748,6 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pci9111_ai_eoc, 0); if (ret) { - data[i] = 0; pci9111_fifo_reset(dev); return ret; } diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 9218e9293cf5..6ca6c429c722 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -614,7 +614,6 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pci9118_ai_eoc, 0); if (ret) { - data[n] = 0; outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return ret; } diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 16c4bb00022c..5978ae63d804 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -469,7 +469,6 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, if (ret) { outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); - data[n] = 0; return ret; } diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 78d44a9c8a71..e5593f8c7406 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -93,10 +93,8 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, udelay(10); ret = comedi_timeout(dev, s, insn, dyna_pci10xx_ai_eoc, 0); - if (ret) { - data[n] = 0; + if (ret) break; - } /* read data */ d = inw_p(dev->iobase); diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index ee30f2b8a54b..0b8b2162b76b 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -215,11 +215,8 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, /* Wait for conversion to complete, or get fed up waiting */ ret = comedi_timeout(dev, s, insn, icp_multi_ai_eoc, 0); - if (ret) { - /* Clear data received */ - data[n] = 0; + if (ret) break; - } data[n] = (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff; diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 4bf2efb2c027..a35f230d1958 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -196,7 +196,6 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, ret = comedi_timeout(dev, s, insn, pcl816_ai_eoc, 0); if (ret) { - data[0] = 0; /* clear INT (conversion end) flag */ outb(0, dev->iobase + PCL816_CLRINT); return ret; From a5e99e126bf61772ccb0ebcc235f5599265cb5b9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:29 -0700 Subject: [PATCH 0236/1375] staging: comedi: usbduxfast: 'cmd->chanlist_len' was already validataed Remove the unnecessary check of 'cmd->chanlist_len > 0'. The (*do_cmdtest) already validated this before the (*do_cmd) was called. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 40 ++++++++++----------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 5f85c55c1109..4a927e44cb0a 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -514,27 +514,25 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, */ devpriv->ignore = PACKETS_TO_IGNORE; - if (cmd->chanlist_len > 0) { - gain = CR_RANGE(cmd->chanlist[0]); - for (i = 0; i < cmd->chanlist_len; ++i) { - chan = CR_CHAN(cmd->chanlist[i]); - if (chan != i) { - dev_err(dev->class_dev, - "channels are not consecutive\n"); - up(&devpriv->sem); - return -EINVAL; - } - if ((gain != CR_RANGE(cmd->chanlist[i])) - && (cmd->chanlist_len > 3)) { - dev_err(dev->class_dev, - "gain must be the same for all channels\n"); - up(&devpriv->sem); - return -EINVAL; - } - if (i >= NUMCHANNELS) { - dev_err(dev->class_dev, "chanlist too long\n"); - break; - } + gain = CR_RANGE(cmd->chanlist[0]); + for (i = 0; i < cmd->chanlist_len; ++i) { + chan = CR_CHAN(cmd->chanlist[i]); + if (chan != i) { + dev_err(dev->class_dev, + "channels are not consecutive\n"); + up(&devpriv->sem); + return -EINVAL; + } + if ((gain != CR_RANGE(cmd->chanlist[i])) + && (cmd->chanlist_len > 3)) { + dev_err(dev->class_dev, + "gain must be the same for all channels\n"); + up(&devpriv->sem); + return -EINVAL; + } + if (i >= NUMCHANNELS) { + dev_err(dev->class_dev, "chanlist too long\n"); + break; } } steps = 0; From 9ebe26cf7acf40391afb6caa4d38bb9cc83a27f0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:30 -0700 Subject: [PATCH 0237/1375] staging: comedi: usbduxfast: remove TRIG_TIMER from scan_begin_src Currently the (*do_cmdtest) indicates that TRIG_TIMER is a valid scan_begin_src but later this source is tested as -EINVAL. To simplify the code a bit just remove the TRIG_TIMER source. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 4a927e44cb0a..d6fae11ee4e0 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -372,7 +372,7 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT | TRIG_INT); err |= cfc_check_trigger_src(&cmd->scan_begin_src, - TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT); + TRIG_FOLLOW | TRIG_EXT); err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT); err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); @@ -424,9 +424,6 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->convert_arg, tmp); } - if (cmd->scan_begin_src == TRIG_TIMER) - err |= -EINVAL; - /* stop source */ switch (cmd->stop_src) { case TRIG_COUNT: @@ -536,12 +533,6 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, } } steps = 0; - if (cmd->scan_begin_src == TRIG_TIMER) { - dev_err(dev->class_dev, - "scan_begin_src==TRIG_TIMER not valid\n"); - up(&devpriv->sem); - return -EINVAL; - } if (cmd->convert_src == TRIG_TIMER) steps = (cmd->convert_arg * 30) / 1000; From bb73fc99bd2a071800e64e985ed464763b9a8d75 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:31 -0700 Subject: [PATCH 0238/1375] staging: comedi: adl_pci9111: trigger sources are validated in (*do_cmdtest) The trigger sources were already validataed in the (*do_cmdtest) before the (*do_cmd) is called. Refactor the code in pci9111_ai_do_cmd() to use if/else instead of the switch since the default cases can never be reached. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 28 +++----------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index ff086d0eedd9..80a0560fa6a8 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -489,29 +489,18 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, dev->iobase + PCI9111_AI_RANGE_STAT_REG); /* Set counter */ - - switch (async_cmd->stop_src) { - case TRIG_COUNT: + if (async_cmd->stop_src == TRIG_COUNT) { dev_private->stop_counter = async_cmd->stop_arg * async_cmd->chanlist_len; dev_private->stop_is_none = 0; - break; - - case TRIG_NONE: + } else { /* TRIG_NONE */ dev_private->stop_counter = 0; dev_private->stop_is_none = 1; - break; - - default: - comedi_error(dev, "Invalid stop trigger"); - return -1; } /* Set timer pacer */ - dev_private->scan_delay = 0; - switch (async_cmd->convert_src) { - case TRIG_TIMER: + if (async_cmd->convert_src == TRIG_TIMER) { pci9111_trigger_source_set(dev, software); pci9111_timer_set(dev); pci9111_fifo_reset(dev); @@ -527,11 +516,7 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, (async_cmd->convert_arg * async_cmd->chanlist_len)) - 1; } - - break; - - case TRIG_EXT: - + } else { /* TRIG_EXT */ pci9111_trigger_source_set(dev, external); pci9111_fifo_reset(dev); pci9111_interrupt_source_set(dev, irq_on_fifo_half_full, @@ -539,11 +524,6 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, plx9050_interrupt_control(dev_private->lcr_io_base, true, true, false, true, true); - break; - - default: - comedi_error(dev, "Invalid convert trigger"); - return -1; } dev_private->stop_counter *= (1 + dev_private->scan_delay); From 654410c90df467184c0ee302ab7103b5b4614291 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:32 -0700 Subject: [PATCH 0239/1375] staging: comedi: cb_das16_cs: remove incomplete async command support This driver has a (*do_cmdtest) function for analog input async command support but the (*do_cmd) function just returns -EINVAL. Remove the incomplete async command support. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_das16_cs.c | 124 ------------------- 1 file changed, 124 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index e0ed193522e0..645fcb0cf17d 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -95,12 +95,6 @@ static const struct comedi_lrange das16cs_ai_range = { } }; -static irqreturn_t das16cs_interrupt(int irq, void *d) -{ - /* struct comedi_device *dev = d; */ - return IRQ_HANDLED; -} - static int das16cs_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -161,117 +155,6 @@ static int das16cs_ai_rinsn(struct comedi_device *dev, return i; } -static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) -{ - return -EINVAL; -} - -static int das16cs_ai_cmdtest(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_cmd *cmd) -{ - int err = 0; - int tmp; - - /* Step 1 : check if triggers are trivially valid */ - - err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); - err |= cfc_check_trigger_src(&cmd->scan_begin_src, - TRIG_TIMER | TRIG_EXT); - err |= cfc_check_trigger_src(&cmd->convert_src, - TRIG_TIMER | TRIG_EXT); - err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); - err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); - - if (err) - return 1; - - /* Step 2a : make sure trigger sources are unique */ - - err |= cfc_check_trigger_is_unique(cmd->scan_begin_src); - err |= cfc_check_trigger_is_unique(cmd->convert_src); - err |= cfc_check_trigger_is_unique(cmd->stop_src); - - /* Step 2b : and mutually compatible */ - - if (err) - return 2; - - /* Step 3: check if arguments are trivially valid */ - - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); - -#define MAX_SPEED 10000 /* in nanoseconds */ -#define MIN_SPEED 1000000000 /* in nanoseconds */ - - if (cmd->scan_begin_src == TRIG_TIMER) { - err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, - MAX_SPEED); - err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, - MIN_SPEED); - } else { - /* external trigger */ - /* should be level/edge, hi/lo specification here */ - /* should specify multiple external triggers */ - err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 9); - } - if (cmd->convert_src == TRIG_TIMER) { - err |= cfc_check_trigger_arg_min(&cmd->convert_arg, - MAX_SPEED); - err |= cfc_check_trigger_arg_max(&cmd->convert_arg, - MIN_SPEED); - } else { - /* external trigger */ - /* see above */ - err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 9); - } - - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); - - if (cmd->stop_src == TRIG_COUNT) - err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff); - else /* TRIG_NONE */ - err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); - - if (err) - return 3; - - /* step 4: fix up any arguments */ - - if (cmd->scan_begin_src == TRIG_TIMER) { - unsigned int div1 = 0, div2 = 0; - - tmp = cmd->scan_begin_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &cmd->scan_begin_arg, cmd->flags); - if (tmp != cmd->scan_begin_arg) - err++; - } - if (cmd->convert_src == TRIG_TIMER) { - unsigned int div1 = 0, div2 = 0; - - tmp = cmd->convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &cmd->scan_begin_arg, cmd->flags); - if (tmp != cmd->convert_arg) - err++; - if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < - cmd->convert_arg * cmd->scan_end_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; - } - } - - if (err) - return 4; - - return 0; -} - static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -409,10 +292,6 @@ static int das16cs_auto_attach(struct comedi_device *dev, dev->iobase = link->resource[0]->start; link->priv = dev; - ret = pcmcia_request_irq(link, das16cs_interrupt); - if (ret) - return ret; - dev->irq = link->irq; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) @@ -423,7 +302,6 @@ static int das16cs_auto_attach(struct comedi_device *dev, return ret; s = &dev->subdevices[0]; - dev->read_subdev = s; /* analog input subdevice */ s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ; @@ -432,8 +310,6 @@ static int das16cs_auto_attach(struct comedi_device *dev, s->range_table = &das16cs_ai_range; s->len_chanlist = 16; s->insn_read = das16cs_ai_rinsn; - s->do_cmd = das16cs_ai_cmd; - s->do_cmdtest = das16cs_ai_cmdtest; s = &dev->subdevices[1]; /* analog output subdevice */ From 8abc7287f6ada9f8378941b81434242db832b5f4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:33 -0700 Subject: [PATCH 0240/1375] staging: comedi: cb_pcidas: trigger sources are validated in (*do_cmdtest) The trigger sources were already validataed in the (*do_cmdtest) before the (*do_cmd) is called. Refactor the code in cb_pcidas_ai_cmd() to remove the final else which can never be reached. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 7d068ebe0575..5452b718f93f 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1017,9 +1017,9 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, /* set start trigger and burst mode */ bits = 0; - if (cmd->start_src == TRIG_NOW) + if (cmd->start_src == TRIG_NOW) { bits |= SW_TRIGGER; - else if (cmd->start_src == TRIG_EXT) { + } else { /* TRIG_EXT */ bits |= EXT_TRIGGER | TGEN | XTRCL; if (thisboard->is_1602) { if (cmd->start_arg & CR_INVERT) @@ -1027,9 +1027,6 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, if (cmd->start_arg & CR_EDGE) bits |= TGSEL; } - } else { - comedi_error(dev, "bug!"); - return -1; } if (cmd->convert_src == TRIG_NOW && cmd->chanlist_len > 1) bits |= BURSTE; From f45cc79ae58ba78f9e7f203f1c7c203b8acb5556 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:34 -0700 Subject: [PATCH 0241/1375] staging: comedi: comedi_test: trigger sources are validated in (*do_cmdtest) The trigger sources were already validataed in the (*do_cmdtest) before the (*do_cmd) is called. Refactor the code in waveform_ai_cmd() to remove the final else which can never be reached. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index d539eaf53b63..3f596669d07a 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -318,12 +318,8 @@ static int waveform_ai_cmd(struct comedi_device *dev, if (cmd->convert_src == TRIG_NOW) devpriv->convert_period = 0; - else if (cmd->convert_src == TRIG_TIMER) + else /* TRIG_TIMER */ devpriv->convert_period = cmd->convert_arg / nano_per_micro; - else { - comedi_error(dev, "bug setting conversion period"); - return -1; - } do_gettimeofday(&devpriv->last); devpriv->usec_current = devpriv->last.tv_usec % devpriv->usec_period; From b41b267dbd17a24657c9bac2150fc1f10061b522 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:35 -0700 Subject: [PATCH 0242/1375] staging: comedi: das800: trigger sources are validated in (*do_cmdtest) The trigger sources were already validataed in the (*do_cmdtest) before the (*do_cmd) is called. Refactor the code in das800_ai_do_cmd() to use if/else instead of the switch since the default cases can never be reached. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index dbe94cea5905..8c15929811b6 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -420,17 +420,12 @@ static int das800_ai_do_cmd(struct comedi_device *dev, gain &= 0xf; outb(gain, dev->iobase + DAS800_GAIN); - switch (async->cmd.stop_src) { - case TRIG_COUNT: + if (async->cmd.stop_src == TRIG_COUNT) { devpriv->count = async->cmd.stop_arg * async->cmd.chanlist_len; devpriv->forever = false; - break; - case TRIG_NONE: + } else { /* TRIG_NONE */ devpriv->forever = true; devpriv->count = 0; - break; - default: - break; } /* enable auto channel scan, send interrupts on end of conversion @@ -440,19 +435,13 @@ static int das800_ai_do_cmd(struct comedi_device *dev, conv_bits |= EACS | IEOC; if (async->cmd.start_src == TRIG_EXT) conv_bits |= DTEN; - switch (async->cmd.convert_src) { - case TRIG_TIMER: + if (async->cmd.convert_src == TRIG_TIMER) { conv_bits |= CASC | ITE; /* set conversion frequency */ if (das800_set_frequency(dev) < 0) { comedi_error(dev, "Error setting up counters"); return -1; } - break; - case TRIG_EXT: - break; - default: - break; } spin_lock_irqsave(&dev->spinlock, irq_flags); From c599235902f653f3eb42546cbf8299da1c445e45 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:36 -0700 Subject: [PATCH 0243/1375] staging: comedi: pcl812: trigger sources were validated in (*do_cmdtest) The trigger sources were already validataed in the (*do_cmdtest) before the (*do_cmd) is called. Remove the unnecessary checks in pcl812_ai_cmd(). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index feb9e98524aa..095b3253054a 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -631,24 +631,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes; struct comedi_cmd *cmd = &s->async->cmd; - if (cmd->start_src != TRIG_NOW) - return -EINVAL; - if (cmd->scan_begin_src != TRIG_FOLLOW) - return -EINVAL; - if (devpriv->use_ext_trg) { - if (cmd->convert_src != TRIG_EXT) - return -EINVAL; - } else { - if (cmd->convert_src != TRIG_TIMER) - return -EINVAL; - } - if (cmd->scan_end_src != TRIG_COUNT) - return -EINVAL; - if (cmd->scan_end_arg != cmd->chanlist_len) - return -EINVAL; - if (cmd->chanlist_len > MAX_CHANLIST_LEN) - return -EINVAL; - if (cmd->convert_src == TRIG_TIMER) { if (cmd->convert_arg < board->ai_ns_min) cmd->convert_arg = board->ai_ns_min; From ab09248c998dd9df4f35912827d95d70b499bd30 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 15:20:37 -0700 Subject: [PATCH 0244/1375] staging: comedi: pcl816: trigger sources were validated in (*do_cmdtest) The trigger sources were already validataed in the (*do_cmdtest) before the (*do_cmd) is called. Remove the unnecessary checks in pcl816_ai_cmd(). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index a35f230d1958..044722f3a51f 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -480,15 +480,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; unsigned int seglen; - if (cmd->start_src != TRIG_NOW) - return -EINVAL; - if (cmd->scan_begin_src != TRIG_FOLLOW) - return -EINVAL; - if (cmd->scan_end_src != TRIG_COUNT) - return -EINVAL; - if (cmd->scan_end_arg != cmd->chanlist_len) - return -EINVAL; -/* if(cmd->chanlist_len>MAX_CHANLIST_LEN) return -EINVAL; */ if (devpriv->irq_blocked) return -EBUSY; From a37d70eb655fdcbcd93b053d11b569cc7b1787eb Mon Sep 17 00:00:00 2001 From: Mark Asselstine Date: Wed, 12 Feb 2014 21:47:56 -0500 Subject: [PATCH 0245/1375] staging: usbip: prevent possible buffer overflow reading port records To avoid buffer overflow while reading a corrupted or possibly modified port file we validate the length of each part of the port record to ensure it doesn't exceed the length of the destination buffer. https://bugzilla.kernel.org/show_bug.cgi?id=69931 Signed-off-by: Mark Asselstine Signed-off-by: Greg Kroah-Hartman --- .../usbip/userspace/libsrc/vhci_driver.c | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c index 209df9b37cb4..f4bfefec5fcc 100644 --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c @@ -339,27 +339,67 @@ err: return -1; } -static int read_record(int rhport, char *host, char *port, char *busid) +/* + * Read the given port's record. + * + * To avoid buffer overflow we will read the entire line and + * validate each part's size. The initial buffer is padded by 4 to + * accommodate the 2 spaces, 1 newline and an additional character + * which is needed to properly validate the 3rd part without it being + * truncated to an acceptable length. + */ +static int read_record(int rhport, char *host, unsigned long host_len, + char *port, unsigned long port_len, char *busid) + { + int part; FILE *file; char path[PATH_MAX+1]; + char *buffer, *start, *end; + char delim[] = {' ', ' ', '\n'}; + int max_len[] = {(int)host_len, (int)port_len, SYSFS_BUS_ID_SIZE}; + size_t buffer_len = host_len + port_len + SYSFS_BUS_ID_SIZE + 4; + + buffer = malloc(buffer_len); + if (!buffer) + return -1; snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport); file = fopen(path, "r"); if (!file) { err("fopen"); + free(buffer); return -1; } - if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) { - err("fscanf"); + if (fgets(buffer, buffer_len, file) == NULL) { + err("fgets"); + free(buffer); fclose(file); return -1; } - fclose(file); + /* validate the length of each of the 3 parts */ + start = buffer; + for (part = 0; part < 3; part++) { + end = strchr(start, delim[part]); + if (end == NULL || (end - start) > max_len[part]) { + free(buffer); + return -1; + } + start = end + 1; + } + + if (sscanf(buffer, "%s %s %s\n", host, port, busid) != 3) { + err("sscanf"); + free(buffer); + return -1; + } + + free(buffer); + return 0; } @@ -573,7 +613,8 @@ int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev) if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED) return 0; - ret = read_record(idev->port, host, serv, remote_busid); + ret = read_record(idev->port, host, sizeof(host), serv, sizeof(serv), + remote_busid); if (ret) { err("read_record"); read_record_error = 1; From cc7c0f7e078a19da3d50fb9ecb7b34d01fd521d2 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Wed, 1 Jan 2014 23:04:00 +0000 Subject: [PATCH 0246/1375] staging:iio:ad799x Move to devm_request_threaded_irq to make device-removal simpler. Signed-off-by: Hartmut Knaack Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad799x_core.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 5708ffc62aec..9c8013c28824 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -577,25 +577,23 @@ static int ad799x_probe(struct i2c_client *client, goto error_disable_reg; if (client->irq > 0) { - ret = request_threaded_irq(client->irq, - NULL, - ad799x_event_handler, - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, - client->name, - indio_dev); + ret = devm_request_threaded_irq(&client->dev, + client->irq, + NULL, + ad799x_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + client->name, + indio_dev); if (ret) goto error_cleanup_ring; } ret = iio_device_register(indio_dev); if (ret) - goto error_free_irq; + goto error_cleanup_ring; return 0; -error_free_irq: - if (client->irq > 0) - free_irq(client->irq, indio_dev); error_cleanup_ring: ad799x_ring_cleanup(indio_dev); error_disable_reg: @@ -611,8 +609,6 @@ static int ad799x_remove(struct i2c_client *client) struct ad799x_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (client->irq > 0) - free_irq(client->irq, indio_dev); ad799x_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) From f9279d3a8cc8e518d21784d0152f04b5ee6635cb Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 1 Oct 2014 21:59:00 +0100 Subject: [PATCH 0247/1375] iio:magnetometer:mag3110: Scale factor missing for temperature temperature is reported in milli-Celsius Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mag3110.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index f66955fb3509..02e4f9765889 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -183,8 +183,17 @@ static int mag3110_read_raw(struct iio_dev *indio_dev, return -EINVAL; } case IIO_CHAN_INFO_SCALE: - *val = 0; - *val2 = 1000; + switch (chan->type) { + case IIO_MAGN: + *val = 0; + *val2 = 1000; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_TEMP: + *val = 1000; + return IIO_VAL_INT; + default: + return -EINVAL; + } return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_SAMP_FREQ: i = data->ctrl_reg1 >> MAG3110_CTRL_DR_SHIFT; @@ -270,7 +279,8 @@ static const struct iio_chan_spec mag3110_channels[] = { MAG3110_CHANNEL(Z, 2), { .type = IIO_TEMP, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), .scan_index = 3, .scan_type = { .sign = 's', From a775427632fd4cb84b12c1176849bf61ea7b4c7c Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Sun, 26 Jan 2014 05:39:00 +0000 Subject: [PATCH 0248/1375] iio:adc:imx: add Freescale Vybrid vf610 adc driver Add Freescale Vybrid vf610 adc driver. The driver only support ADC software trigger. VF610 ADC device documentation is available at below reference manual (chapter 37): http://cache.freescale.com/files/32bit/doc/ref_manual/VYBRIDRM.pdf? fpsp=1&WT_TYPE=Reference%20Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT =pdf&WT_ASSET=Documentation CC: Shawn Guo CC: Jonathan Cameron CC: Mark Rutland CC: Otavio Salvador CC: Peter Meerwald CC: Lars-Peter Clausen Signed-off-by: Fugang Duan Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/vf610_adc.c | 711 ++++++++++++++++++++++++++++++++++++ 3 files changed, 722 insertions(+) create mode 100644 drivers/iio/adc/vf610_adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 2209f28441e9..c02c4fb4cd1d 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -197,6 +197,16 @@ config TWL6030_GPADC This driver can also be built as a module. If so, the module will be called twl6030-gpadc. +config VF610_ADC + tristate "Freescale vf610 ADC driver" + depends on OF + help + Say yes here to support for Vybrid board analog-to-digital converter. + Since the IP is used for i.MX6SLX, the driver also support i.MX6SLX. + + This driver can also be built as a module. If so, the module will be + called vf610_adc. + config VIPERBOARD_ADC tristate "Viperboard ADC support" depends on MFD_VIPERBOARD && USB diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index ba9a10a24cd0..6d96b0fd2a25 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -21,4 +21,5 @@ obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o obj-$(CONFIG_TWL6030_GPADC) += twl6030-gpadc.o +obj-$(CONFIG_VF610_ADC) += vf610_adc.o obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c new file mode 100644 index 000000000000..37f542e8233c --- /dev/null +++ b/drivers/iio/adc/vf610_adc.c @@ -0,0 +1,711 @@ +/* + * Freescale Vybrid vf610 ADC driver + * + * Copyright 2013 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* This will be the driver name the kernel reports */ +#define DRIVER_NAME "vf610-adc" + +/* Vybrid/IMX ADC registers */ +#define VF610_REG_ADC_HC0 0x00 +#define VF610_REG_ADC_HC1 0x04 +#define VF610_REG_ADC_HS 0x08 +#define VF610_REG_ADC_R0 0x0c +#define VF610_REG_ADC_R1 0x10 +#define VF610_REG_ADC_CFG 0x14 +#define VF610_REG_ADC_GC 0x18 +#define VF610_REG_ADC_GS 0x1c +#define VF610_REG_ADC_CV 0x20 +#define VF610_REG_ADC_OFS 0x24 +#define VF610_REG_ADC_CAL 0x28 +#define VF610_REG_ADC_PCTL 0x30 + +/* Configuration register field define */ +#define VF610_ADC_MODE_BIT8 0x00 +#define VF610_ADC_MODE_BIT10 0x04 +#define VF610_ADC_MODE_BIT12 0x08 +#define VF610_ADC_MODE_MASK 0x0c +#define VF610_ADC_BUSCLK2_SEL 0x01 +#define VF610_ADC_ALTCLK_SEL 0x02 +#define VF610_ADC_ADACK_SEL 0x03 +#define VF610_ADC_ADCCLK_MASK 0x03 +#define VF610_ADC_CLK_DIV2 0x20 +#define VF610_ADC_CLK_DIV4 0x40 +#define VF610_ADC_CLK_DIV8 0x60 +#define VF610_ADC_CLK_MASK 0x60 +#define VF610_ADC_ADLSMP_LONG 0x10 +#define VF610_ADC_ADSTS_MASK 0x300 +#define VF610_ADC_ADLPC_EN 0x80 +#define VF610_ADC_ADHSC_EN 0x400 +#define VF610_ADC_REFSEL_VALT 0x100 +#define VF610_ADC_REFSEL_VBG 0x1000 +#define VF610_ADC_ADTRG_HARD 0x2000 +#define VF610_ADC_AVGS_8 0x4000 +#define VF610_ADC_AVGS_16 0x8000 +#define VF610_ADC_AVGS_32 0xC000 +#define VF610_ADC_AVGS_MASK 0xC000 +#define VF610_ADC_OVWREN 0x10000 + +/* General control register field define */ +#define VF610_ADC_ADACKEN 0x1 +#define VF610_ADC_DMAEN 0x2 +#define VF610_ADC_ACREN 0x4 +#define VF610_ADC_ACFGT 0x8 +#define VF610_ADC_ACFE 0x10 +#define VF610_ADC_AVGEN 0x20 +#define VF610_ADC_ADCON 0x40 +#define VF610_ADC_CAL 0x80 + +/* Other field define */ +#define VF610_ADC_ADCHC(x) ((x) & 0xF) +#define VF610_ADC_AIEN (0x1 << 7) +#define VF610_ADC_CONV_DISABLE 0x1F +#define VF610_ADC_HS_COCO0 0x1 +#define VF610_ADC_CALF 0x2 +#define VF610_ADC_TIMEOUT msecs_to_jiffies(100) + +enum clk_sel { + VF610_ADCIOC_BUSCLK_SET, + VF610_ADCIOC_ALTCLK_SET, + VF610_ADCIOC_ADACK_SET, +}; + +enum vol_ref { + VF610_ADCIOC_VR_VREF_SET, + VF610_ADCIOC_VR_VALT_SET, + VF610_ADCIOC_VR_VBG_SET, +}; + +enum average_sel { + VF610_ADC_SAMPLE_1, + VF610_ADC_SAMPLE_4, + VF610_ADC_SAMPLE_8, + VF610_ADC_SAMPLE_16, + VF610_ADC_SAMPLE_32, +}; + +struct vf610_adc_feature { + enum clk_sel clk_sel; + enum vol_ref vol_ref; + + int clk_div; + int sample_rate; + int res_mode; + + bool lpm; + bool calibration; + bool ovwren; +}; + +struct vf610_adc { + struct device *dev; + void __iomem *regs; + struct clk *clk; + + u32 vref_uv; + u32 value; + struct regulator *vref; + struct vf610_adc_feature adc_feature; + + struct completion completion; +}; + +#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), \ +} + +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), + /* sentinel */ +}; + +/* + * ADC sample frequency, unit is ADCK cycles. + * ADC clk source is ipg clock, which is the same as bus clock. + * + * ADC conversion time = SFCAdder + AverageNum x (BCT + LSTAdder) + * SFCAdder: fixed to 6 ADCK cycles + * AverageNum: 1, 4, 8, 16, 32 samples for hardware average. + * BCT (Base Conversion Time): fixed to 25 ADCK cycles for 12 bit mode + * LSTAdder(Long Sample Time): fixed to 3 ADCK cycles + * + * By default, enable 12 bit resolution mode, clock source + * set to ipg clock, So get below frequency group: + */ +static const u32 vf610_sample_freq_avail[5] = +{1941176, 559332, 286957, 145374, 73171}; + +static inline void vf610_adc_cfg_init(struct vf610_adc *info) +{ + /* set default Configuration for ADC controller */ + info->adc_feature.clk_sel = VF610_ADCIOC_BUSCLK_SET; + info->adc_feature.vol_ref = VF610_ADCIOC_VR_VREF_SET; + + info->adc_feature.calibration = true; + info->adc_feature.ovwren = true; + + info->adc_feature.clk_div = 1; + info->adc_feature.res_mode = 12; + info->adc_feature.sample_rate = 1; + info->adc_feature.lpm = true; +} + +static void vf610_adc_cfg_post_set(struct vf610_adc *info) +{ + struct vf610_adc_feature *adc_feature = &info->adc_feature; + int cfg_data = 0; + int gc_data = 0; + + switch (adc_feature->clk_sel) { + case VF610_ADCIOC_ALTCLK_SET: + cfg_data |= VF610_ADC_ALTCLK_SEL; + break; + case VF610_ADCIOC_ADACK_SET: + cfg_data |= VF610_ADC_ADACK_SEL; + break; + default: + break; + } + + /* low power set for calibration */ + cfg_data |= VF610_ADC_ADLPC_EN; + + /* enable high speed for calibration */ + cfg_data |= VF610_ADC_ADHSC_EN; + + /* voltage reference */ + switch (adc_feature->vol_ref) { + case VF610_ADCIOC_VR_VREF_SET: + break; + case VF610_ADCIOC_VR_VALT_SET: + cfg_data |= VF610_ADC_REFSEL_VALT; + break; + case VF610_ADCIOC_VR_VBG_SET: + cfg_data |= VF610_ADC_REFSEL_VBG; + break; + default: + dev_err(info->dev, "error voltage reference\n"); + } + + /* data overwrite enable */ + if (adc_feature->ovwren) + cfg_data |= VF610_ADC_OVWREN; + + writel(cfg_data, info->regs + VF610_REG_ADC_CFG); + writel(gc_data, info->regs + VF610_REG_ADC_GC); +} + +static void vf610_adc_calibration(struct vf610_adc *info) +{ + int adc_gc, hc_cfg; + int timeout; + + if (!info->adc_feature.calibration) + return; + + /* enable calibration interrupt */ + hc_cfg = VF610_ADC_AIEN | VF610_ADC_CONV_DISABLE; + writel(hc_cfg, info->regs + VF610_REG_ADC_HC0); + + adc_gc = readl(info->regs + VF610_REG_ADC_GC); + writel(adc_gc | VF610_ADC_CAL, info->regs + VF610_REG_ADC_GC); + + timeout = wait_for_completion_timeout + (&info->completion, VF610_ADC_TIMEOUT); + if (timeout == 0) + dev_err(info->dev, "Timeout for adc calibration\n"); + + adc_gc = readl(info->regs + VF610_REG_ADC_GS); + if (adc_gc & VF610_ADC_CALF) + dev_err(info->dev, "ADC calibration failed\n"); + + info->adc_feature.calibration = false; +} + +static void vf610_adc_cfg_set(struct vf610_adc *info) +{ + struct vf610_adc_feature *adc_feature = &(info->adc_feature); + int cfg_data; + + cfg_data = readl(info->regs + VF610_REG_ADC_CFG); + + /* low power configuration */ + cfg_data &= ~VF610_ADC_ADLPC_EN; + if (adc_feature->lpm) + cfg_data |= VF610_ADC_ADLPC_EN; + + /* disable high speed */ + cfg_data &= ~VF610_ADC_ADHSC_EN; + + writel(cfg_data, info->regs + VF610_REG_ADC_CFG); +} + +static void vf610_adc_sample_set(struct vf610_adc *info) +{ + struct vf610_adc_feature *adc_feature = &(info->adc_feature); + int cfg_data, gc_data; + + cfg_data = readl(info->regs + VF610_REG_ADC_CFG); + gc_data = readl(info->regs + VF610_REG_ADC_GC); + + /* resolution mode */ + cfg_data &= ~VF610_ADC_MODE_MASK; + switch (adc_feature->res_mode) { + case 8: + cfg_data |= VF610_ADC_MODE_BIT8; + break; + case 10: + cfg_data |= VF610_ADC_MODE_BIT10; + break; + case 12: + cfg_data |= VF610_ADC_MODE_BIT12; + break; + default: + dev_err(info->dev, "error resolution mode\n"); + break; + } + + /* clock select and clock divider */ + cfg_data &= ~(VF610_ADC_CLK_MASK | VF610_ADC_ADCCLK_MASK); + switch (adc_feature->clk_div) { + case 1: + break; + case 2: + cfg_data |= VF610_ADC_CLK_DIV2; + break; + case 4: + cfg_data |= VF610_ADC_CLK_DIV4; + break; + case 8: + cfg_data |= VF610_ADC_CLK_DIV8; + break; + case 16: + switch (adc_feature->clk_sel) { + case VF610_ADCIOC_BUSCLK_SET: + cfg_data |= VF610_ADC_BUSCLK2_SEL | VF610_ADC_CLK_DIV8; + break; + default: + dev_err(info->dev, "error clk divider\n"); + break; + } + break; + } + + /* Use the short sample mode */ + cfg_data &= ~(VF610_ADC_ADLSMP_LONG | VF610_ADC_ADSTS_MASK); + + /* update hardware average selection */ + cfg_data &= ~VF610_ADC_AVGS_MASK; + gc_data &= ~VF610_ADC_AVGEN; + switch (adc_feature->sample_rate) { + case VF610_ADC_SAMPLE_1: + break; + case VF610_ADC_SAMPLE_4: + gc_data |= VF610_ADC_AVGEN; + break; + case VF610_ADC_SAMPLE_8: + gc_data |= VF610_ADC_AVGEN; + cfg_data |= VF610_ADC_AVGS_8; + break; + case VF610_ADC_SAMPLE_16: + gc_data |= VF610_ADC_AVGEN; + cfg_data |= VF610_ADC_AVGS_16; + break; + case VF610_ADC_SAMPLE_32: + gc_data |= VF610_ADC_AVGEN; + cfg_data |= VF610_ADC_AVGS_32; + break; + default: + dev_err(info->dev, + "error hardware sample average select\n"); + } + + writel(cfg_data, info->regs + VF610_REG_ADC_CFG); + writel(gc_data, info->regs + VF610_REG_ADC_GC); +} + +static void vf610_adc_hw_init(struct vf610_adc *info) +{ + /* CFG: Feature set */ + vf610_adc_cfg_post_set(info); + vf610_adc_sample_set(info); + + /* adc calibration */ + vf610_adc_calibration(info); + + /* CFG: power and speed set */ + vf610_adc_cfg_set(info); +} + +static int vf610_adc_read_data(struct vf610_adc *info) +{ + int result; + + result = readl(info->regs + VF610_REG_ADC_R0); + + switch (info->adc_feature.res_mode) { + case 8: + result &= 0xFF; + break; + case 10: + result &= 0x3FF; + break; + case 12: + result &= 0xFFF; + break; + default: + break; + } + + return result; +} + +static irqreturn_t vf610_adc_isr(int irq, void *dev_id) +{ + struct vf610_adc *info = (struct vf610_adc *)dev_id; + int coco; + + coco = readl(info->regs + VF610_REG_ADC_HS); + if (coco & VF610_ADC_HS_COCO0) { + info->value = vf610_adc_read_data(info); + complete(&info->completion); + } + + return IRQ_HANDLED; +} + +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("1941176, 559332, 286957, 145374, 73171"); + +static struct attribute *vf610_attributes[] = { + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group vf610_attribute_group = { + .attrs = vf610_attributes, +}; + +static int vf610_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) +{ + struct vf610_adc *info = iio_priv(indio_dev); + unsigned int hc_cfg; + unsigned long ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&indio_dev->mlock); + reinit_completion(&info->completion); + + hc_cfg = VF610_ADC_ADCHC(chan->channel); + hc_cfg |= VF610_ADC_AIEN; + writel(hc_cfg, info->regs + VF610_REG_ADC_HC0); + ret = wait_for_completion_interruptible_timeout + (&info->completion, VF610_ADC_TIMEOUT); + if (ret == 0) { + mutex_unlock(&indio_dev->mlock); + return -ETIMEDOUT; + } + if (ret < 0) { + mutex_unlock(&indio_dev->mlock); + return ret; + } + + *val = info->value; + mutex_unlock(&indio_dev->mlock); + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + *val = info->vref_uv / 1000; + *val2 = info->adc_feature.res_mode; + return IIO_VAL_FRACTIONAL_LOG2; + + case IIO_CHAN_INFO_SAMP_FREQ: + *val = vf610_sample_freq_avail[info->adc_feature.sample_rate]; + *val2 = 0; + return IIO_VAL_INT; + + default: + break; + } + + return -EINVAL; +} + +static int vf610_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct vf610_adc *info = iio_priv(indio_dev); + int i; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + for (i = 0; + i < ARRAY_SIZE(vf610_sample_freq_avail); + i++) + if (val == vf610_sample_freq_avail[i]) { + info->adc_feature.sample_rate = i; + vf610_adc_sample_set(info); + return 0; + } + break; + + default: + break; + } + + return -EINVAL; +} + +static int vf610_adc_reg_access(struct iio_dev *indio_dev, + unsigned reg, unsigned writeval, + unsigned *readval) +{ + struct vf610_adc *info = iio_priv(indio_dev); + + if ((readval == NULL) || + (!(reg % 4) || (reg > VF610_REG_ADC_PCTL))) + return -EINVAL; + + *readval = readl(info->regs + reg); + + return 0; +} + +static const struct iio_info vf610_adc_iio_info = { + .driver_module = THIS_MODULE, + .read_raw = &vf610_read_raw, + .write_raw = &vf610_write_raw, + .debugfs_reg_access = &vf610_adc_reg_access, + .attrs = &vf610_attribute_group, +}; + +static const struct of_device_id vf610_adc_match[] = { + { .compatible = "fsl,vf610-adc", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, vf610_adc_match); + +static int vf610_adc_probe(struct platform_device *pdev) +{ + struct vf610_adc *info; + struct iio_dev *indio_dev; + struct resource *mem; + int irq; + int ret; + + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc)); + if (!indio_dev) { + dev_err(&pdev->dev, "Failed allocating iio device\n"); + return -ENOMEM; + } + + info = iio_priv(indio_dev); + info->dev = &pdev->dev; + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + info->regs = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(info->regs)) + return PTR_ERR(info->regs); + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { + dev_err(&pdev->dev, "no irq resource?\n"); + return -EINVAL; + } + + ret = devm_request_irq(info->dev, irq, + vf610_adc_isr, 0, + dev_name(&pdev->dev), info); + if (ret < 0) { + dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", irq); + return ret; + } + + info->clk = devm_clk_get(&pdev->dev, "adc"); + if (IS_ERR(info->clk)) { + dev_err(&pdev->dev, "failed getting clock, err = %ld\n", + PTR_ERR(info->clk)); + ret = PTR_ERR(info->clk); + return ret; + } + + info->vref = devm_regulator_get(&pdev->dev, "vref"); + if (IS_ERR(info->vref)) + return PTR_ERR(info->vref); + + ret = regulator_enable(info->vref); + if (ret) + return ret; + + info->vref_uv = regulator_get_voltage(info->vref); + + platform_set_drvdata(pdev, indio_dev); + + init_completion(&info->completion); + + indio_dev->name = dev_name(&pdev->dev); + indio_dev->dev.parent = &pdev->dev; + indio_dev->dev.of_node = pdev->dev.of_node; + indio_dev->info = &vf610_adc_iio_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = vf610_adc_iio_channels; + indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels); + + ret = clk_prepare_enable(info->clk); + if (ret) { + dev_err(&pdev->dev, + "Could not prepare or enable the clock.\n"); + goto error_adc_clk_enable; + } + + vf610_adc_cfg_init(info); + vf610_adc_hw_init(info); + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(&pdev->dev, "Couldn't register the device.\n"); + goto error_iio_device_register; + } + + return 0; + + +error_iio_device_register: + clk_disable_unprepare(info->clk); +error_adc_clk_enable: + regulator_disable(info->vref); + + return ret; +} + +static int vf610_adc_remove(struct platform_device *pdev) +{ + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct vf610_adc *info = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + regulator_disable(info->vref); + clk_disable_unprepare(info->clk); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int vf610_adc_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct vf610_adc *info = iio_priv(indio_dev); + int hc_cfg; + + /* ADC controller enters to stop mode */ + hc_cfg = readl(info->regs + VF610_REG_ADC_HC0); + hc_cfg |= VF610_ADC_CONV_DISABLE; + writel(hc_cfg, info->regs + VF610_REG_ADC_HC0); + + clk_disable_unprepare(info->clk); + regulator_disable(info->vref); + + return 0; +} + +static int vf610_adc_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct vf610_adc *info = iio_priv(indio_dev); + int ret; + + ret = regulator_enable(info->vref); + if (ret) + return ret; + + ret = clk_prepare_enable(info->clk); + if (ret) + return ret; + + vf610_adc_hw_init(info); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, + vf610_adc_suspend, + vf610_adc_resume); + +static struct platform_driver vf610_adc_driver = { + .probe = vf610_adc_probe, + .remove = vf610_adc_remove, + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + .of_match_table = vf610_adc_match, + .pm = &vf610_adc_pm_ops, + }, +}; + +module_platform_driver(vf610_adc_driver); + +MODULE_AUTHOR("Fugang Duan "); +MODULE_DESCRIPTION("Freescale VF610 ADC driver"); +MODULE_LICENSE("GPL v2"); From 33be5fd1c9a9e1c092205abbdea6ada0956c93a8 Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Sun, 26 Jan 2014 05:39:00 +0000 Subject: [PATCH 0249/1375] Documentation: add the binding file for Freescale vf610 ADC driver The patch adds the binding file for Freescale vf610 ADC driver. CC: Shawn Guo CC: Jonathan Cameron CC: Mark Rutland CC: Otavio Salvador CC: Peter Meerwald CC: Lars-Peter Clausen Signed-off-by: Fugang Duan Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/vf610-adc.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/vf610-adc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt b/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt new file mode 100644 index 000000000000..dcebff1928e1 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/vf610-adc.txt @@ -0,0 +1,22 @@ +Freescale vf610 Analog to Digital Converter bindings + +The devicetree bindings are for the new ADC driver written for +vf610/i.MX6slx and upward SoCs from Freescale. + +Required properties: +- compatible: Should contain "fsl,vf610-adc" +- reg: Offset and length of the register set for the device +- interrupts: Should contain the interrupt for the device +- clocks: The clock is needed by the ADC controller, ADC clock source is ipg clock. +- clock-names: Must contain "adc", matching entry in the clocks property. +- vref-supply: The regulator supply ADC refrence voltage. + +Example: +adc0: adc@4003b000 { + compatible = "fsl,vf610-adc"; + reg = <0x4003b000 0x1000>; + interrupts = <0 53 0x04>; + clocks = <&clks VF610_CLK_ADC0>; + clock-names = "adc"; + vref-supply = <®_vcc_3v3_mcu>; +}; From 07d4655b410a4da3bdffbc9ed01d9fef67f682a6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 12 Nov 2013 18:45:00 +0000 Subject: [PATCH 0250/1375] iio:drop IIO_ST macro This macro no longer allows all the elements of the scan_type structure to be set. Missinterpretation of the parameters also caused a couple of recent bugs. No mainline drivers now use this macro so drop it. Signed-off-by: Jonathan Cameron --- include/linux/iio/iio.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 75a8a20c8179..5f2d00e7e488 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -254,12 +254,16 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, (chan->info_mask_shared_by_all & BIT(type)); } -#define IIO_ST(si, rb, sb, sh) \ - { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } - -#define IIO_CHAN_SOFT_TIMESTAMP(_si) \ - { .type = IIO_TIMESTAMP, .channel = -1, \ - .scan_index = _si, .scan_type = IIO_ST('s', 64, 64, 0) } +#define IIO_CHAN_SOFT_TIMESTAMP(_si) { \ + .type = IIO_TIMESTAMP, \ + .channel = -1, \ + .scan_index = _si, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 64, \ + .storagebits = 64, \ + }, \ +} /** * iio_get_time_ns() - utility function to get a time stamp for events etc From 5c1449d41e339b7b335dc3fd562d08107175452f Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 1 Oct 2014 21:37:00 +0100 Subject: [PATCH 0251/1375] iio:accel:bma180: Make LOW_PASS_FILTER_3DB_FREQUENCY shared_by_type the property is not per-channel, but shared by type Signed-off-by: Peter Meerwald Cc: Kravchenko Oleksandr Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bma180.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index bfec313492b3..a7e68c81f89d 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -451,9 +451,9 @@ static const struct iio_chan_spec_ext_info bma180_ext_info[] = { .type = IIO_ACCEL, \ .modified = 1, \ .channel2 = IIO_MOD_##_axis, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ .scan_index = AXIS_##_axis, \ .scan_type = { \ .sign = 's', \ From 49d916ec2a62be865c727da0413b05b9e2bcbd65 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Fri, 2 May 2014 13:23:00 +0100 Subject: [PATCH 0252/1375] staging: iio: Add tool to list IIO devices and triggers Signed-off-by: Manuel Stahl Signed-off-by: Jonathan Cameron --- drivers/staging/iio/Documentation/iio_utils.h | 22 +++ drivers/staging/iio/Documentation/lsiio.c | 157 ++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 drivers/staging/iio/Documentation/lsiio.c diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h index c9fedb79e3a2..2064839ef2cd 100644 --- a/drivers/staging/iio/Documentation/iio_utils.h +++ b/drivers/staging/iio/Documentation/iio_utils.h @@ -652,3 +652,25 @@ error_free: free(temp); return ret; } + +read_sysfs_string(const char *filename, const char *basedir, char *str) +{ + float ret = 0; + FILE *sysfsfp; + char *temp = malloc(strlen(basedir) + strlen(filename) + 2); + if (temp == NULL) { + printf("Memory allocation failed"); + return -ENOMEM; + } + sprintf(temp, "%s/%s", basedir, filename); + sysfsfp = fopen(temp, "r"); + if (sysfsfp == NULL) { + ret = -errno; + goto error_free; + } + fscanf(sysfsfp, "%s\n", str); + fclose(sysfsfp); +error_free: + free(temp); + return ret; +} diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c new file mode 100644 index 000000000000..24ae9694eb41 --- /dev/null +++ b/drivers/staging/iio/Documentation/lsiio.c @@ -0,0 +1,157 @@ +/* + * Industrial I/O utilities - lsiio.c + * + * Copyright (c) 2010 Manuel Stahl + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "iio_utils.h" + + +static enum verbosity { + VERBLEVEL_DEFAULT, /* 0 gives lspci behaviour */ + VERBLEVEL_SENSORS, /* 1 lists sensors */ +} verblevel = VERBLEVEL_DEFAULT; + +const char *type_device = "iio:device"; +const char *type_trigger = "trigger"; + + +static inline int check_prefix(const char *str, const char *prefix) +{ + return strlen(str) > strlen(prefix) && + strncmp(str, prefix, strlen(prefix)) == 0; +} + +static inline int check_postfix(const char *str, const char *postfix) +{ + return strlen(str) > strlen(postfix) && + strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; +} + +static int dump_channels(const char *dev_dir_name) +{ + DIR *dp; + const struct dirent *ent; + dp = opendir(dev_dir_name); + if (dp == NULL) + return -errno; + while (ent = readdir(dp), ent != NULL) + if (check_prefix(ent->d_name, "in_") && + check_postfix(ent->d_name, "_raw")) { + printf(" %-10s\n", ent->d_name); + } + + return 0; +} + +static int dump_one_device(const char *dev_dir_name) +{ + char name[IIO_MAX_NAME_LENGTH]; + int dev_idx; + + sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device), + "%i", &dev_idx); + read_sysfs_string("name", dev_dir_name, name); + printf("Device %03d: %s\n", dev_idx, name); + + if (verblevel >= VERBLEVEL_SENSORS) { + int ret = dump_channels(dev_dir_name); + if (ret) + return ret; + } + return 0; +} + +static int dump_one_trigger(const char *dev_dir_name) +{ + char name[IIO_MAX_NAME_LENGTH]; + int dev_idx; + + sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger), + "%i", &dev_idx); + read_sysfs_string("name", dev_dir_name, name); + printf("Trigger %03d: %s\n", dev_idx, name); + return 0; +} + +static void dump_devices(void) +{ + const struct dirent *ent; + int number, numstrlen; + + FILE *nameFile; + DIR *dp; + char thisname[IIO_MAX_NAME_LENGTH]; + char *filename; + + dp = opendir(iio_dir); + if (dp == NULL) { + printf("No industrial I/O devices available\n"); + return; + } + + while (ent = readdir(dp), ent != NULL) { + if (check_prefix(ent->d_name, type_device)) { + char *dev_dir_name; + asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name); + dump_one_device(dev_dir_name); + free(dev_dir_name); + if (verblevel >= VERBLEVEL_SENSORS) + printf("\n"); + } + } + rewinddir(dp); + while (ent = readdir(dp), ent != NULL) { + if (check_prefix(ent->d_name, type_trigger)) { + char *dev_dir_name; + asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name); + dump_one_trigger(dev_dir_name); + free(dev_dir_name); + } + } + closedir(dp); +} + +int main(int argc, char **argv) +{ + int c, err = 0; + + while ((c = getopt(argc, argv, "d:D:v")) != EOF) { + switch (c) { + case 'v': + verblevel++; + break; + + case '?': + default: + err++; + break; + } + } + 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" + ); + exit(1); + } + + dump_devices(); + + return 0; +} From 9610e08e97370ca7780bea977b03355fa0261635 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 14 Feb 2014 03:28:00 +0000 Subject: [PATCH 0253/1375] iio: mxs-lradc: Propagate the real error code on platform_get_irq() failure No need to return a 'fake' return value on platform_get_irq() failure. Just return the error code itself instead. Signed-off-by: Fabio Estevam Acked-by: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index d304156ca2f7..ab3c0d4ba68e 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -1558,7 +1558,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) for (i = 0; i < of_cfg->irq_count; i++) { lradc->irq[i] = platform_get_irq(pdev, i); if (lradc->irq[i] < 0) - return -EINVAL; + return lradc->irq[i]; ret = devm_request_irq(dev, lradc->irq[i], mxs_lradc_handle_irq, 0, From ec97423afbd09c566fc3e756b4a6b50695dda0af Mon Sep 17 00:00:00 2001 From: Levente Kurusa Date: Fri, 14 Feb 2014 22:50:23 +0100 Subject: [PATCH 0254/1375] staging: rtl8821ae: fix invalid bit mask on MSR_AP check Since MSR_AP is 0x3, ANDing it with 0xFC will never be true. Add a NOT operation to 0xFC so that we will AND with the last three bits which will result in a possibility that the condition will succeed. Signed-off-by: Levente Kurusa Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.c b/drivers/staging/rtl8821ae/rtl8821ae/hw.c index e8344be92344..d3e9b93400bf 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.c @@ -1623,7 +1623,7 @@ static int _rtl8821ae_set_media_status(struct ieee80211_hw *hw, rtl_write_byte(rtlpriv, (MSR), bt_msr); rtlpriv->cfg->ops->led_control(hw, ledaction); - if ((bt_msr & 0xfc) == MSR_AP) + if ((bt_msr & ~0xfc) == MSR_AP) rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00); else rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66); From 4bb101d4f21be51e0f10ca71440e34858ce7b827 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 15 Feb 2014 08:36:11 +0100 Subject: [PATCH 0255/1375] staging: r8712u: delete unnecessary field initialization On success, the function netdev_alloc_skb initializes the dev field of its result to its first argument, so this doesn't have to be done in the calling context. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression skb,privn,e; @@ skb = netdev_alloc_skb(privn,...); ... when strict ( -skb->dev = privn; | ?skb = e ) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index ea965370d1ac..0723b2f73aad 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -90,7 +90,6 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter) pskb = netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); if (pskb) { - pskb->dev = padapter->pnetdev; tmpaddr = (addr_t)pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); @@ -1083,7 +1082,6 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) alloc_sz += 6; pkt_copy = netdev_alloc_skb(padapter->pnetdev, alloc_sz); if (pkt_copy) { - pkt_copy->dev = padapter->pnetdev; precvframe->u.hdr.pkt = pkt_copy; skb_reserve(pkt_copy, 4 - ((addr_t)(pkt_copy->data) % 4)); From 44630dee03d6c7f143668e7629d073198091b63c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:05 -0600 Subject: [PATCH 0256/1375] staging: r8188eu: Remove unnecessary list_head entry from recv_frame union Struct recv_frame_hdr already contains a list head. This one is pointless. Suggested-by: Jes Sorensen Signed-off-by: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 7 ++++--- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 794785eb54e1..2291b10bf1d1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -87,9 +87,10 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvframe = (union recv_frame *)precvpriv->precv_frame_buf; for (i = 0; i < NR_RECVFRAME; i++) { - _rtw_init_listhead(&(precvframe->u.list)); + _rtw_init_listhead(&(precvframe->u.hdr.list)); - rtw_list_insert_tail(&(precvframe->u.list), &(precvpriv->free_recv_queue.queue)); + rtw_list_insert_tail(&(precvframe->u.hdr.list), + &(precvpriv->free_recv_queue.queue)); res = rtw_os_recv_resource_alloc(padapter, precvframe); @@ -1485,7 +1486,7 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queu plist = phead->next; pfhdr = container_of(plist, struct recv_frame_hdr, list); prframe = (union recv_frame *)pfhdr; - rtw_list_delete(&(prframe->u.list)); + rtw_list_delete(&(prframe->u.hdr.list)); if (curfragnum != pfhdr->attrib.frag_num) { /* the first fragment number must be 0 */ diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index be9c30c57419..866c9e47011d 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -291,7 +291,6 @@ struct recv_frame_hdr { union recv_frame { union { - struct list_head list; struct recv_frame_hdr hdr; uint mem[RECVFRAME_HDR_ALIGN>>2]; } u; From 34fdae8dd88f37ff1fbd40d6470b98d730b0a6f0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:06 -0600 Subject: [PATCH 0257/1375] staging: r8188eu: Remove pointless "alignment" entry in recv_frame This alignment entry in union recv_frame does nothing. It certainly dues not ensure alignment. Suggested-by: Jes.Sorensen@redhat.com Signed-off-by: Larry Finger Cc: Jes.Sorensen@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 866c9e47011d..c6d7a659e9d1 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -292,7 +292,6 @@ struct recv_frame_hdr { union recv_frame { union { struct recv_frame_hdr hdr; - uint mem[RECVFRAME_HDR_ALIGN>>2]; } u; }; From f31cca8e920728ab8d3472791dd551c5e993f051 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:07 -0600 Subject: [PATCH 0258/1375] staging: r8188eu: Remove union wrapping of recv_frame We have now removed everthing from the union except the struct. The union can be deleted, the struct renamed, and the referencing of members of the struct becomes a lot simpler. Some, but not all, of the problems noted by checkpatch.pl have been fixed. Sugggested-by: Jes Sorensen Signed-off-by: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 143 ++++---- drivers/staging/rtl8188eu/core/rtw_recv.c | 343 ++++++++++-------- drivers/staging/rtl8188eu/core/rtw_security.c | 18 +- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 10 +- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 31 +- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 38 +- .../staging/rtl8188eu/include/recv_osdep.h | 10 +- .../staging/rtl8188eu/include/rtl8188e_recv.h | 7 +- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 49 +-- drivers/staging/rtl8188eu/include/rtw_recv.h | 106 +++--- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 36 +- 11 files changed, 413 insertions(+), 378 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 301cda51e4a9..faeec73aec78 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -414,10 +414,10 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) } } -static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, union recv_frame *precv_frame) +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->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; if (ptable->func) { /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ @@ -428,7 +428,7 @@ static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptabl } } -void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) { int index; struct mlme_handler *ptable; @@ -436,7 +436,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; + 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_, @@ -465,13 +465,15 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) if (psta != NULL) { if (GetRetry(pframe)) { - if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) { + 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->u.hdr.attrib.seq_num); + DBG_88E("Drop duplicate management frame with seq_num=%d.\n", + precv_frame->attrib.seq_num); return; } } - psta->RxMgmtFrameSeqNum = precv_frame->u.hdr.attrib.seq_num; + psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; } #ifdef CONFIG_88EU_AP_MODE @@ -532,7 +534,7 @@ Following are the callback functions for each subtype of the management frames *****************************************************************************/ -unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned int ielen; unsigned char *p; @@ -540,8 +542,8 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; u8 is_valid_p2p_probereq = false; #ifdef CONFIG_88EU_P2P @@ -609,12 +611,12 @@ _issue_probersp: return _SUCCESS; } -unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; #ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; #endif #ifdef CONFIG_88EU_P2P @@ -663,7 +665,7 @@ unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; @@ -671,8 +673,8 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; struct wlan_bssid_ex *pbss; int ret = _SUCCESS; @@ -753,7 +755,7 @@ _END_ONBEACON_: return _SUCCESS; } -unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE unsigned int auth_mode, ie_len; @@ -767,8 +769,8 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -926,15 +928,15 @@ auth_fail: return _FAIL; } -unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.rx_data; - uint pkt_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; DBG_88E("%s\n", __func__); @@ -1001,7 +1003,7 @@ authclnt_fail: return _FAIL; } -unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE u16 capab_info; @@ -1020,8 +1022,8 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; - uint pkt_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; #ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &(padapter->wdinfo); u8 p2p_status_code = P2P_STATUS_SUCCESS; @@ -1470,7 +1472,7 @@ OnAssocReqFail: return _FAIL; } -unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) { uint i; int res; @@ -1480,8 +1482,8 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; - uint pkt_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; DBG_88E("%s\n", __func__); @@ -1560,13 +1562,13 @@ report_assoc_result: return _SUCCESS; } -unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; #ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &(padapter->wdinfo); #endif /* CONFIG_88EU_P2P */ @@ -1624,13 +1626,13 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; #ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &(padapter->wdinfo); #endif /* CONFIG_88EU_P2P */ @@ -1687,18 +1689,18 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame) +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, union recv_frame *precv_frame) +unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned int ret = _FAIL; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = (u8 *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); u8 category; u8 action; @@ -1731,17 +1733,17 @@ exit: return ret; } -unsigned int OnAction_qos(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_dls(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_dls(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; @@ -1751,7 +1753,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra 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->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), @@ -3857,13 +3859,13 @@ exit: #endif /* CONFIG_88EU_P2P */ -static s32 rtw_action_public_decache(union recv_frame *recv_frame, s32 token) +static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { - struct adapter *adapter = recv_frame->u.hdr.adapter; + struct adapter *adapter = recv_frame->adapter; struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); - u8 *frame = recv_frame->u.hdr.rx_data; - u16 seq_ctrl = ((recv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | - (recv_frame->u.hdr.attrib.frag_num & 0xf); + 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) { @@ -3889,14 +3891,14 @@ static s32 rtw_action_public_decache(union recv_frame *recv_frame, s32 token) return _SUCCESS; } -static unsigned int on_action_public_p2p(union recv_frame *precv_frame) +static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) { - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body; u8 dialogToken = 0; #ifdef CONFIG_88EU_P2P - struct adapter *padapter = precv_frame->u.hdr.adapter; - uint len = precv_frame->u.hdr.len; + struct adapter *padapter = precv_frame->adapter; + uint len = precv_frame->len; u8 *p2p_ie; u32 p2p_ielen; struct wifidirect_info *pwdinfo = &(padapter->wdinfo); @@ -4180,10 +4182,10 @@ static unsigned int on_action_public_p2p(union recv_frame *precv_frame) return _SUCCESS; } -static unsigned int on_action_public_vendor(union recv_frame *precv_frame) +static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) { unsigned int ret = _FAIL; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); if (!memcmp(frame_body + 2, P2P_OUI, 4)) @@ -4192,10 +4194,10 @@ static unsigned int on_action_public_vendor(union recv_frame *precv_frame) return ret; } -static unsigned int on_action_public_default(union recv_frame *precv_frame, u8 action) +static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) { unsigned int ret = _FAIL; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); u8 token; @@ -4210,10 +4212,10 @@ exit: return ret; } -unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned int ret = _FAIL; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); u8 category, action; @@ -4239,23 +4241,23 @@ exit: return ret; } -unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_ht(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_wmm(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_p2p(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_P2P u8 *frame_body; u8 category, OUI_Subtype; - u8 *pframe = precv_frame->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; struct wifidirect_info *pwdinfo = &(padapter->wdinfo); @@ -4294,13 +4296,13 @@ unsigned int OnAction_p2p(struct adapter *padapter, union recv_frame *precv_fram return _SUCCESS; } -unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); @@ -4314,7 +4316,7 @@ unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int DoReserved(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } @@ -6530,14 +6532,14 @@ void site_survey(struct adapter *padapter) } /* collect bss info from Beacon and Probe request/response frames. */ -u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) { int i; u32 len; u8 *p; u16 val16, subtype; - u8 *pframe = precv_frame->u.hdr.rx_data; - u32 packet_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + u32 packet_len = precv_frame->len; u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6576,10 +6578,10 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str bssid->IELength = len; memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); - /* get the signal strength */ - bssid->Rssi = precv_frame->u.hdr.attrib.phy_info.recvpower; /* in dBM.raw data */ - bssid->PhyInfo.SignalQuality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ + /* get the signal strength in dBM.raw data */ + bssid->Rssi = precv_frame->attrib.phy_info.recvpower; + bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ + bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ rtw_hal_get_def_var(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); /* checking SSID */ @@ -7032,7 +7034,8 @@ Following are the functions to report events *****************************************************************************/ -void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame) +void report_survey_event(struct adapter *padapter, + struct recv_frame *precv_frame) { struct cmd_obj *pcmd_obj; u8 *pevtcmd; @@ -7041,8 +7044,6 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame struct C2HEvent_Header *pc2h_evt_hdr; struct mlme_ext_priv *pmlmeext; struct cmd_priv *pcmdpriv; - /* u8 *pframe = precv_frame->u.hdr.rx_data; */ - /* uint len = precv_frame->u.hdr.len; */ if (!padapter) return; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 2291b10bf1d1..3333ae90f8bf 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -59,7 +59,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) { int i; - union recv_frame *precvframe; + struct recv_frame *precvframe; int res = _SUCCESS; @@ -75,7 +75,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) rtw_os_recv_resource_init(precvpriv, padapter); - precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); if (precvpriv->pallocated_frame_buf == NULL) { res = _FAIL; @@ -84,19 +84,19 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); - precvframe = (union recv_frame *)precvpriv->precv_frame_buf; + precvframe = (struct recv_frame *)precvpriv->precv_frame_buf; for (i = 0; i < NR_RECVFRAME; i++) { - _rtw_init_listhead(&(precvframe->u.hdr.list)); + _rtw_init_listhead(&(precvframe->list)); - rtw_list_insert_tail(&(precvframe->u.hdr.list), + rtw_list_insert_tail(&(precvframe->list), &(precvpriv->free_recv_queue.queue)); res = rtw_os_recv_resource_alloc(padapter, precvframe); - precvframe->u.hdr.len = 0; + precvframe->len = 0; - precvframe->u.hdr.adapter = padapter; + precvframe->adapter = padapter; precvframe++; } precvpriv->rx_pending_cnt = 1; @@ -133,9 +133,9 @@ void _rtw_free_recv_priv (struct recv_priv *precvpriv) } -union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +struct recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) { - struct recv_frame_hdr *hdr; + struct recv_frame *hdr; struct list_head *plist, *phead; struct adapter *padapter; struct recv_priv *precvpriv; @@ -147,7 +147,7 @@ union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) plist = phead->next; - hdr = container_of(plist, struct recv_frame_hdr, list); + hdr = container_of(plist, struct recv_frame, list); rtw_list_delete(&hdr->list); padapter = hdr->adapter; @@ -159,12 +159,12 @@ union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) } - return (union recv_frame *)hdr; + return (struct recv_frame *)hdr; } -union recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue) { - union recv_frame *precvframe; + struct recv_frame *precvframe; spin_lock_bh(&pfree_recv_queue->lock); @@ -175,35 +175,36 @@ union recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) return precvframe; } -void rtw_init_recvframe(union recv_frame *precvframe, struct recv_priv *precvpriv) +void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv) { /* Perry: This can be removed */ - _rtw_init_listhead(&precvframe->u.hdr.list); + _rtw_init_listhead(&precvframe->list); - precvframe->u.hdr.len = 0; + precvframe->len = 0; } -int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_queue) +int rtw_free_recvframe(struct recv_frame *precvframe, + struct __queue *pfree_recv_queue) { struct adapter *padapter; struct recv_priv *precvpriv; if (!precvframe) return _FAIL; - padapter = precvframe->u.hdr.adapter; + padapter = precvframe->adapter; precvpriv = &padapter->recvpriv; - if (precvframe->u.hdr.pkt) { - dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ - precvframe->u.hdr.pkt = NULL; + if (precvframe->pkt) { + dev_kfree_skb_any(precvframe->pkt);/* free skb by driver */ + precvframe->pkt = NULL; } spin_lock_bh(&pfree_recv_queue->lock); - rtw_list_delete(&(precvframe->u.hdr.list)); + rtw_list_delete(&(precvframe->list)); - precvframe->u.hdr.len = 0; + precvframe->len = 0; - rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(pfree_recv_queue)); + rtw_list_insert_tail(&(precvframe->list), get_list_head(pfree_recv_queue)); if (padapter != NULL) { if (pfree_recv_queue == &precvpriv->free_recv_queue) @@ -216,14 +217,14 @@ int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_ return _SUCCESS; } -int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) { - struct adapter *padapter = precvframe->u.hdr.adapter; + struct adapter *padapter = precvframe->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; - rtw_list_delete(&(precvframe->u.hdr.list)); - rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(queue)); + rtw_list_delete(&(precvframe->list)); + rtw_list_insert_tail(&(precvframe->list), get_list_head(queue)); if (padapter != NULL) { if (queue == &precvpriv->free_recv_queue) @@ -234,7 +235,7 @@ int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) return _SUCCESS; } -int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) { int ret; @@ -255,7 +256,7 @@ using spinlock to protect void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) { - struct recv_frame_hdr *hdr; + struct recv_frame *hdr; struct list_head *plist, *phead; spin_lock(&pframequeue->lock); @@ -264,11 +265,11 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre plist = phead->next; while (rtw_end_of_queue_search(phead, plist) == false) { - hdr = container_of(plist, struct recv_frame_hdr, list); + hdr = container_of(plist, struct recv_frame, list); plist = plist->next; - rtw_free_recvframe((union recv_frame *)hdr, pfree_recv_queue); + rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue); } spin_unlock(&pframequeue->lock); @@ -278,7 +279,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) { u32 cnt = 0; - union recv_frame *pending_frame; + struct recv_frame *pending_frame; while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); DBG_88E("%s: dequeue uc_swdec_pending_queue\n", __func__); @@ -337,7 +338,8 @@ struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) return precvbuf; } -static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) +static int recvframe_chkmic(struct adapter *adapter, + struct recv_frame *precvframe) { int i, res = _SUCCESS; u32 datalen; @@ -346,7 +348,7 @@ static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvfra u8 *pframe, *payload, *pframemic; u8 *mickey; struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; @@ -376,8 +378,10 @@ static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvfra RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); } - datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ - pframe = precvframe->u.hdr.rx_data; + /* icv_len included the mic code */ + datalen = precvframe->len-prxattrib->hdrlen - + prxattrib->iv_len-prxattrib->icv_len-8; + pframe = precvframe->rx_data; payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len)); @@ -410,16 +414,30 @@ static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvfra *(pframemic-10), *(pframemic-9))); { uint i; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len=%d)======\n", precvframe->u.hdr.len)); - for (i = 0; i < precvframe->u.hdr.len; i = i+8) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", - *(precvframe->u.hdr.rx_data+i), *(precvframe->u.hdr.rx_data+i+1), - *(precvframe->u.hdr.rx_data+i+2), *(precvframe->u.hdr.rx_data+i+3), - *(precvframe->u.hdr.rx_data+i+4), *(precvframe->u.hdr.rx_data+i+5), - *(precvframe->u.hdr.rx_data+i+6), *(precvframe->u.hdr.rx_data+i+7))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n ======demp packet (len=%d)======\n", + precvframe->len)); + for (i = 0; i < precvframe->len; i += 8) { + RT_TRACE(_module_rtl871x_recv_c_, + _drv_err_, + ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", + *(precvframe->rx_data+i), + *(precvframe->rx_data+i+1), + *(precvframe->rx_data+i+2), + *(precvframe->rx_data+i+3), + *(precvframe->rx_data+i+4), + *(precvframe->rx_data+i+5), + *(precvframe->rx_data+i+6), + *(precvframe->rx_data+i+7))); } - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ====== demp packet end [len=%d]======\n", precvframe->u.hdr.len)); - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n hrdlen=%d,\n", prxattrib->hdrlen)); + RT_TRACE(_module_rtl871x_recv_c_, + _drv_err_, + ("\n ====== demp packet end [len=%d]======\n", + precvframe->len)); + RT_TRACE(_module_rtl871x_recv_c_, + _drv_err_, + ("\n hrdlen=%d,\n", + prxattrib->hdrlen)); } RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, @@ -462,17 +480,18 @@ exit: } /* decrypt and set the ivlen, icvlen of the recv_frame */ -static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame) +static struct recv_frame *decryptor(struct adapter *padapter, + struct recv_frame *precv_frame) { - struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &precv_frame->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; - union recv_frame *return_packet = precv_frame; + struct recv_frame *return_packet = precv_frame; u32 res = _SUCCESS; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted=%x prxattrib->encrypt=0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); if (prxattrib->encrypt > 0) { - u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen; + u8 *iv = precv_frame->rx_data+prxattrib->hdrlen; prxattrib->key_index = (((iv[3])>>6)&0x3); if (prxattrib->key_index > WEP_KEYS) { @@ -523,14 +542,15 @@ static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *p } /* set the security information in the recv_frame */ -static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame) +static struct recv_frame *portctrl(struct adapter *adapter, + struct recv_frame *precv_frame) { u8 *psta_addr = NULL, *ptr; uint auth_alg; - struct recv_frame_hdr *pfhdr; + struct recv_frame *pfhdr; struct sta_info *psta; struct sta_priv *pstapriv; - union recv_frame *prtnframe; + struct recv_frame *prtnframe; u16 ether_type = 0; u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; @@ -543,7 +563,7 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre auth_alg = adapter->securitypriv.dot11AuthAlgrthm; ptr = get_recvframe_data(precv_frame); - pfhdr = &precv_frame->u.hdr; + pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; @@ -575,7 +595,9 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre /* allowed */ /* check decryption status, and decrypt the frame if needed */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==0\n")); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", precv_frame->u.hdr.attrib.privacy)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", + precv_frame->attrib.privacy)); if (pattrib->bdecrypted == 0) RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted=%x\n", pattrib->bdecrypted)); @@ -599,12 +621,13 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre return prtnframe; } -static int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache) +static int recv_decache(struct recv_frame *precv_frame, u8 bretry, + struct stainfo_rxcache *prxcache) { - int tid = precv_frame->u.hdr.attrib.priority; + int tid = precv_frame->attrib.priority; - u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | - (precv_frame->u.hdr.attrib.frag_num & 0xf); + u16 seq_ctrl = ((precv_frame->attrib.seq_num&0xffff) << 4) | + (precv_frame->attrib.frag_num & 0xf); if (tid > 15) { @@ -627,13 +650,13 @@ static int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo return _SUCCESS; } -void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame); -void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame) +void process_pwrbit_data(struct adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE unsigned char pwrbit; - u8 *ptr = precv_frame->u.hdr.rx_data; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; @@ -654,10 +677,11 @@ void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame #endif } -static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame) +static void process_wmmps_data(struct adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; @@ -709,12 +733,14 @@ static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv #endif } -static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta) +static void count_rx_stats(struct adapter *padapter, + struct recv_frame *prframe, + struct sta_info *sta) { int sz; struct sta_info *psta = NULL; struct stainfo_stats *pstats = NULL; - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &prframe->attrib; struct recv_priv *precvpriv = &padapter->recvpriv; sz = get_recvframe_len(prframe); @@ -728,7 +754,7 @@ static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, if (sta) psta = sta; else - psta = prframe->u.hdr.psta; + psta = prframe->psta; if (psta) { pstats = &psta->sta_stats; @@ -740,15 +766,16 @@ static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, int sta2sta_data_frame( struct adapter *adapter, - union recv_frame *precv_frame, + struct recv_frame *precv_frame, struct sta_info **psta ); -int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, struct sta_info **psta) +int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, + struct sta_info **psta) { - u8 *ptr = precv_frame->u.hdr.rx_data; + u8 *ptr = precv_frame->rx_data; int ret = _SUCCESS; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *mybssid = get_bssid(pmlmepriv); @@ -836,11 +863,11 @@ exit: static int ap2sta_data_frame ( struct adapter *adapter, - union recv_frame *precv_frame, + struct recv_frame *precv_frame, struct sta_info **psta) { - u8 *ptr = precv_frame->u.hdr.rx_data; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; int ret = _SUCCESS; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -945,13 +972,13 @@ exit: } static int sta2ap_data_frame(struct adapter *adapter, - union recv_frame *precv_frame, + struct recv_frame *precv_frame, struct sta_info **psta) { - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *ptr = precv_frame->u.hdr.rx_data; + u8 *ptr = precv_frame->rx_data; unsigned char *mybssid = get_bssid(pmlmepriv); int ret = _SUCCESS; @@ -1005,13 +1032,12 @@ exit: } static int validate_recv_ctrl_frame(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; - /* uint len = precv_frame->u.hdr.len; */ + u8 *pframe = precv_frame->rx_data; if (GetFrameType(pframe) != WIFI_CTRL_TYPE) return _FAIL; @@ -1130,10 +1156,11 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, return _FAIL; } -union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame); +struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, + struct recv_frame *precv_frame); static int validate_recv_mgnt_frame(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { struct sta_info *psta; @@ -1146,19 +1173,20 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, } /* for rx pkt statistics */ - psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->u.hdr.rx_data)); + psta = rtw_get_stainfo(&padapter->stapriv, + GetAddr2Ptr(precv_frame->rx_data)); if (psta) { psta->sta_stats.rx_mgnt_pkts++; - if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_BEACON) { + if (GetFrameSubType(precv_frame->rx_data) == WIFI_BEACON) { psta->sta_stats.rx_beacon_pkts++; - } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBEREQ) { + } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBEREQ) { psta->sta_stats.rx_probereq_pkts++; - } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBERSP) { + } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBERSP) { if (!memcmp(padapter->eeprompriv.mac_addr, - GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN)) + GetAddr1Ptr(precv_frame->rx_data), ETH_ALEN)) psta->sta_stats.rx_probersp_pkts++; - else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) || - is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) + else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->rx_data)) || + is_multicast_mac_addr(GetAddr1Ptr(precv_frame->rx_data))) psta->sta_stats.rx_probersp_bm_pkts++; else psta->sta_stats.rx_probersp_uo_pkts++; @@ -1171,13 +1199,13 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, } static int validate_recv_data_frame(struct adapter *adapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { u8 bretry; u8 *psa, *pda, *pbssid; struct sta_info *psta = NULL; - u8 *ptr = precv_frame->u.hdr.rx_data; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct security_priv *psecuritypriv = &adapter->securitypriv; int ret = _SUCCESS; @@ -1238,7 +1266,7 @@ static int validate_recv_data_frame(struct adapter *adapter, /* psta->rssi = prxcmd->rssi; */ /* psta->signal_quality = prxcmd->sq; */ - precv_frame->u.hdr.psta = psta; + precv_frame->psta = psta; pattrib->amsdu = 0; pattrib->ack_policy = 0; @@ -1259,7 +1287,7 @@ static int validate_recv_data_frame(struct adapter *adapter, if (pattrib->order)/* HT-CTRL 11n */ pattrib->hdrlen += 4; - precv_frame->u.hdr.preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; + precv_frame->preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; /* decache, drop duplicate recv packets */ if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { @@ -1289,7 +1317,8 @@ exit: return ret; } -static int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame) +static int validate_recv_frame(struct adapter *adapter, + struct recv_frame *precv_frame) { /* shall check frame subtype, to / from ds, da, bssid */ @@ -1299,8 +1328,8 @@ static int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_ u8 subtype; int retval = _SUCCESS; u8 bDumpRxPkt; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; - u8 *ptr = precv_frame->u.hdr.rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + u8 *ptr = precv_frame->rx_data; u8 ver = (unsigned char) (*ptr)&0x3; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; @@ -1399,7 +1428,7 @@ exit: /* remove the wlanhdr and add the eth_hdr */ -static int wlanhdr_to_ethhdr (union recv_frame *precvframe) +static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) { int rmv_len; u16 eth_type, len; @@ -1409,11 +1438,11 @@ static int wlanhdr_to_ethhdr (union recv_frame *precvframe) struct ieee80211_snap_hdr *psnap; int ret = _SUCCESS; - struct adapter *adapter = precvframe->u.hdr.adapter; + struct adapter *adapter = precvframe->adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ - struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precvframe->attrib; if (pattrib->encrypt) @@ -1434,7 +1463,7 @@ static int wlanhdr_to_ethhdr (union recv_frame *precvframe) } rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); - len = precvframe->u.hdr.len - rmv_len; + len = precvframe->len - rmv_len; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len)); @@ -1469,13 +1498,14 @@ static int wlanhdr_to_ethhdr (union recv_frame *precvframe) } /* perform defrag */ -static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) +static struct recv_frame *recvframe_defrag(struct adapter *adapter, + struct __queue *defrag_q) { struct list_head *plist, *phead; u8 wlanhdr_offset; u8 curfragnum; - struct recv_frame_hdr *pfhdr, *pnfhdr; - union recv_frame *prframe, *pnextrframe; + struct recv_frame *pfhdr, *pnfhdr; + struct recv_frame *prframe, *pnextrframe; struct __queue *pfree_recv_queue; @@ -1484,9 +1514,9 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queu phead = get_list_head(defrag_q); plist = phead->next; - pfhdr = container_of(plist, struct recv_frame_hdr, list); - prframe = (union recv_frame *)pfhdr; - rtw_list_delete(&(prframe->u.hdr.list)); + pfhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)pfhdr; + rtw_list_delete(&(prframe->list)); if (curfragnum != pfhdr->attrib.frag_num) { /* the first fragment number must be 0 */ @@ -1504,8 +1534,8 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queu plist = plist->next; while (rtw_end_of_queue_search(phead, plist) == false) { - pnfhdr = container_of(plist, struct recv_frame_hdr , list); - pnextrframe = (union recv_frame *)pnfhdr; + pnfhdr = container_of(plist, struct recv_frame, list); + pnextrframe = (struct recv_frame *)pnfhdr; /* check the fragment sequence (2nd ~n fragment frame) */ @@ -1548,22 +1578,23 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queu } /* check if need to defrag, if needed queue the frame to defrag_q */ -union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame) +struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, + struct recv_frame *precv_frame) { u8 ismfrag; u8 fragnum; u8 *psta_addr; - struct recv_frame_hdr *pfhdr; + struct recv_frame *pfhdr; struct sta_info *psta; struct sta_priv *pstapriv; struct list_head *phead; - union recv_frame *prtnframe = NULL; + struct recv_frame *prtnframe = NULL; struct __queue *pfree_recv_queue, *pdefrag_q; pstapriv = &padapter->stapriv; - pfhdr = &precv_frame->u.hdr; + pfhdr = precv_frame; pfree_recv_queue = &padapter->recvpriv.free_recv_queue; @@ -1635,7 +1666,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram } } - if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) { + if ((prtnframe != NULL) && (prtnframe->attrib.privacy)) { /* after defrag we must check tkip mic code */ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); @@ -1648,7 +1679,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram return prtnframe; } -static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) +static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) { int a_len, padding_len; u16 eth_type, nSubframe_Length; @@ -1662,16 +1693,16 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) int ret = _SUCCESS; nr_subframes = 0; - pattrib = &prframe->u.hdr.attrib; + pattrib = &prframe->attrib; - recvframe_pull(prframe, prframe->u.hdr.attrib.hdrlen); + recvframe_pull(prframe, prframe->attrib.hdrlen); - if (prframe->u.hdr.attrib.iv_len > 0) - recvframe_pull(prframe, prframe->u.hdr.attrib.iv_len); + if (prframe->attrib.iv_len > 0) + recvframe_pull(prframe, prframe->attrib.iv_len); - a_len = prframe->u.hdr.len; + a_len = prframe->len; - pdata = prframe->u.hdr.rx_data; + pdata = prframe->rx_data; while (a_len > ETH_HLEN) { /* Offset 12 denote 2 mac address */ @@ -1693,7 +1724,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); memcpy(data_ptr, pdata, nSubframe_Length); } else { - sub_skb = skb_clone(prframe->u.hdr.pkt, GFP_ATOMIC); + sub_skb = skb_clone(prframe->pkt, GFP_ATOMIC); if (sub_skb) { sub_skb->data = pdata; sub_skb->len = nSubframe_Length; @@ -1760,7 +1791,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) exit: - prframe->u.hdr.len = 0; + prframe->len = 0; rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ return ret; @@ -1796,20 +1827,20 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n return true; } -int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe); -int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe) +int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, + struct recv_frame *prframe) { - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &prframe->attrib; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; struct list_head *phead, *plist; - struct recv_frame_hdr *hdr; + struct recv_frame *hdr; struct rx_pkt_attrib *pnextattrib; phead = get_list_head(ppending_recvframe_queue); plist = phead->next; while (rtw_end_of_queue_search(phead, plist) == false) { - hdr = container_of(plist, struct recv_frame_hdr, list); + hdr = container_of(plist, struct recv_frame, list); pnextattrib = &hdr->attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) @@ -1820,17 +1851,17 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec break; } - rtw_list_delete(&(prframe->u.hdr.list)); + rtw_list_delete(&(prframe->list)); - rtw_list_insert_tail(&(prframe->u.hdr.list), plist); + rtw_list_insert_tail(&(prframe->list), plist); return true; } static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) { struct list_head *phead, *plist; - union recv_frame *prframe; - struct recv_frame_hdr *prhdr; + struct recv_frame *prframe; + struct recv_frame *prhdr; struct rx_pkt_attrib *pattrib; int bPktInBuf = false; struct recv_priv *precvpriv = &padapter->recvpriv; @@ -1844,7 +1875,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor if (rtw_is_list_empty(phead)) return true; - prhdr = container_of(plist, struct recv_frame_hdr, list); + prhdr = container_of(plist, struct recv_frame, list); pattrib = &prhdr->attrib; preorder_ctrl->indicate_seq = pattrib->seq_num; } @@ -1852,16 +1883,16 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor /* Prepare indication list and indication. */ /* Check if there is any packet need indicate. */ while (!rtw_is_list_empty(phead)) { - prhdr = container_of(plist, struct recv_frame_hdr, list); - prframe = (union recv_frame *)prhdr; - pattrib = &prframe->u.hdr.attrib; + prhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)prhdr; + pattrib = &prframe->attrib; if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_indicatepkts_in_order: indicate=%d seq=%d amsdu=%d\n", preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); plist = plist->next; - rtw_list_delete(&(prframe->u.hdr.list)); + rtw_list_delete(&(prframe->list)); if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; @@ -1890,11 +1921,12 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor return bPktInBuf; } -static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe) +static int recv_indicatepkt_reorder(struct adapter *padapter, + struct recv_frame *prframe) { int retval = _SUCCESS; - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; - struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl; + struct rx_pkt_attrib *pattrib = &prframe->attrib; + struct recv_reorder_ctrl *preorder_ctrl = prframe->preorder_ctrl; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; if (!pattrib->amsdu) { @@ -1998,17 +2030,14 @@ void rtw_reordering_ctrl_timeout_handler(void *pcontext) spin_unlock_bh(&ppending_recvframe_queue->lock); } -static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe) +static int process_recv_indicatepkts(struct adapter *padapter, + struct recv_frame *prframe) { int retval = _SUCCESS; - /* struct recv_priv *precvpriv = &padapter->recvpriv; */ - /* struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; if (phtpriv->ht_option) { /* B/G/N Mode */ - /* prframe->u.hdr.preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */ - if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { /* including perform A-MPDU Rx Ordering Buffer Control */ if ((!padapter->bDriverStopped) && @@ -2041,10 +2070,11 @@ static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame return retval; } -static int recv_func_prehandle(struct adapter *padapter, union recv_frame *rframe) +static int recv_func_prehandle(struct adapter *padapter, + struct recv_frame *rframe) { int ret = _SUCCESS; - struct rx_pkt_attrib *pattrib = &rframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &rframe->attrib; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2076,10 +2106,11 @@ exit: return ret; } -static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prframe) +static int recv_func_posthandle(struct adapter *padapter, + struct recv_frame *prframe) { int ret = _SUCCESS; - union recv_frame *orig_prframe = prframe; + struct recv_frame *orig_prframe = prframe; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; @@ -2121,16 +2152,16 @@ _recv_data_drop: return ret; } -static int recv_func(struct adapter *padapter, union recv_frame *rframe) +static int recv_func(struct adapter *padapter, struct recv_frame *rframe) { int ret; - struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &rframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *mlmepriv = &padapter->mlmepriv; /* check if need to handle uc_swdec_pending_queue*/ if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) { - union recv_frame *pending_frame; + struct recv_frame *pending_frame; while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) { if (recv_func_posthandle(padapter, pending_frame) == _SUCCESS) @@ -2159,14 +2190,14 @@ exit: return ret; } -s32 rtw_recv_entry(union recv_frame *precvframe) +s32 rtw_recv_entry(struct recv_frame *precvframe) { struct adapter *padapter; struct recv_priv *precvpriv; s32 ret = _SUCCESS; - padapter = precvframe->u.hdr.adapter; + padapter = precvframe->adapter; precvpriv = &padapter->recvpriv; diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index c3ce56989ea6..c4b16ea6348a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -205,11 +205,11 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) u32 keylength; u8 *pframe, *payload, *iv, wepkey[16]; u8 keyindex; - struct rx_pkt_attrib *prxattrib = &(((union recv_frame *)precvframe)->u.hdr.attrib); + struct rx_pkt_attrib *prxattrib = &(((struct recv_frame *)precvframe)->attrib); struct security_priv *psecuritypriv = &padapter->securitypriv; - pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* start to decrypt recvframe */ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { @@ -218,7 +218,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) keylength = psecuritypriv->dot11DefKeylen[keyindex]; memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; @@ -653,12 +653,12 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; - pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* 4 start to decrypt recvframe */ if (prxattrib->encrypt == _TKIP_) { @@ -678,7 +678,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) iv = pframe+prxattrib->hdrlen; payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; GET_TKIP_PN(iv, dot11txpn); @@ -1455,10 +1455,10 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) int length; u8 *pframe, *prwskey; /* *payload,*iv */ struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; - pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* 4 start to encrypt each fragment */ if ((prxattrib->encrypt == _AES_)) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); @@ -1482,7 +1482,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); } else { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index a59f062aa2e4..2d0b60686a01 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -346,8 +346,8 @@ u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ for (i = 0; i < 16; i++) { struct list_head *phead, *plist; - struct recv_frame_hdr *prhdr; - union recv_frame *prframe; + struct recv_frame *prhdr; + struct recv_frame *prframe; struct __queue *ppending_recvframe_queue; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; @@ -363,12 +363,12 @@ u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) plist = phead->next; while (!rtw_is_list_empty(phead)) { - prhdr = container_of(plist, struct recv_frame_hdr, list); - prframe = (union recv_frame *)prhdr; + prhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)prhdr; plist = plist->next; - rtw_list_delete(&(prframe->u.hdr.list)); + rtw_list_delete(&(prframe->list)); rtw_free_recvframe(prframe, pfree_recv_queue); } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c index 4e3630646bd1..f29bb79a757b 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -23,9 +23,9 @@ #include #include -static void process_rssi(struct adapter *padapter, union recv_frame *prframe) +static void process_rssi(struct adapter *padapter, struct recv_frame *prframe) { - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &prframe->attrib; struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; if (signal_stat->update_req) { @@ -39,7 +39,8 @@ static void process_rssi(struct adapter *padapter, union recv_frame *prframe) signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; } /* Process_UI_RSSI_8192C */ -static void process_link_qual(struct adapter *padapter, union recv_frame *prframe) +static void process_link_qual(struct adapter *padapter, + struct recv_frame *prframe) { struct rx_pkt_attrib *pattrib; struct signal_stat *signal_stat; @@ -47,7 +48,7 @@ static void process_link_qual(struct adapter *padapter, union recv_frame *prfram if (prframe == NULL || padapter == NULL) return; - pattrib = &prframe->u.hdr.attrib; + pattrib = &prframe->attrib; signal_stat = &padapter->recvpriv.signal_qual_data; if (signal_stat->update_req) { @@ -63,7 +64,7 @@ static void process_link_qual(struct adapter *padapter, union recv_frame *prfram void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) { - union recv_frame *precvframe = (union recv_frame *)prframe; + struct recv_frame *precvframe = (struct recv_frame *)prframe; /* Check RSSI */ process_rssi(padapter, precvframe); @@ -71,7 +72,8 @@ void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) process_link_qual(padapter, precvframe); } -void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat *prxstat) +void update_recvframe_attrib_88e(struct recv_frame *precvframe, + struct recv_stat *prxstat) { struct rx_pkt_attrib *pattrib; struct recv_stat report; @@ -83,7 +85,7 @@ void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat report.rxdw4 = prxstat->rxdw4; report.rxdw5 = prxstat->rxdw5; - pattrib = &precvframe->u.hdr.attrib; + pattrib = &precvframe->attrib; _rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);/* u8)prxreport->crc32; */ @@ -136,12 +138,13 @@ void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat /* * Notice: * Before calling this function, - * precvframe->u.hdr.rx_data should be ready! + * precvframe->rx_data should be ready! */ -void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat *pphy_status) +void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, + struct phy_stat *pphy_status) { - struct adapter *padapter = precvframe->u.hdr.adapter; - struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + struct adapter *padapter = precvframe->adapter; + struct rx_pkt_attrib *pattrib = &precvframe->attrib; struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); u8 *wlanhdr; @@ -185,17 +188,17 @@ void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); - precvframe->u.hdr.psta = NULL; + precvframe->psta = NULL; if (pkt_info.bPacketMatchBSSID && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { if (psta) { - precvframe->u.hdr.psta = psta; + precvframe->psta = psta; rtl8188e_process_phy_info(padapter, precvframe); } } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { if (psta) - precvframe->u.hdr.psta = psta; + precvframe->psta = psta; } rtl8188e_process_phy_info(padapter, precvframe); } diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index 74ee2e6ae902..1bfe497ebf4e 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -306,7 +306,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) struct recv_stat *prxstat; struct phy_stat *pphy_status = NULL; struct sk_buff *pkt_copy = NULL; - union recv_frame *precvframe = NULL; + struct recv_frame *precvframe = NULL; struct rx_pkt_attrib *pattrib = NULL; struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); struct recv_priv *precvpriv = &adapt->recvpriv; @@ -332,13 +332,13 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) goto _exit_recvbuf2recvframe; } - _rtw_init_listhead(&precvframe->u.hdr.list); - precvframe->u.hdr.precvbuf = NULL; /* can't access the precvbuf for new arch. */ - precvframe->u.hdr.len = 0; + _rtw_init_listhead(&precvframe->list); + precvframe->precvbuf = NULL; /* can't access the precvbuf for new arch. */ + precvframe->len = 0; update_recvframe_attrib_88e(precvframe, prxstat); - pattrib = &precvframe->u.hdr.attrib; + pattrib = &precvframe->attrib; if ((pattrib->crc_err) || (pattrib->icv_err)) { DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); @@ -385,26 +385,26 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); if (pkt_copy) { pkt_copy->dev = adapt->pnetdev; - precvframe->u.hdr.pkt = pkt_copy; - precvframe->u.hdr.rx_head = pkt_copy->data; - precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz; + precvframe->pkt = pkt_copy; + precvframe->rx_head = pkt_copy->data; + precvframe->rx_end = pkt_copy->data + alloc_sz; skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); - precvframe->u.hdr.rx_tail = pkt_copy->data; - precvframe->u.hdr.rx_data = pkt_copy->data; + precvframe->rx_tail = pkt_copy->data; + precvframe->rx_data = pkt_copy->data; } else { if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } - precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC); - if (precvframe->u.hdr.pkt) { - precvframe->u.hdr.rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; - precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_tail; - precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail; - precvframe->u.hdr.rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; + precvframe->pkt = skb_clone(pskb, GFP_ATOMIC); + if (precvframe->pkt) { + precvframe->rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; + precvframe->rx_head = precvframe->rx_tail; + precvframe->rx_data = precvframe->rx_tail; + precvframe->rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; } else { DBG_88E("recvbuf2recvframe: skb_clone fail\n"); rtw_free_recvframe(precvframe, pfree_recv_queue); @@ -437,17 +437,17 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) /* enqueue recvframe to txrtp queue */ if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX-TXRPT ack for xmit mgmt frames. */ - handle_txrpt_ccx_88e(adapt, precvframe->u.hdr.rx_data); + handle_txrpt_ccx_88e(adapt, precvframe->rx_data); } else if (pattrib->pkt_rpt_type == TX_REPORT2) { ODM_RA_TxRPT2Handle_8188E( &haldata->odmpriv, - precvframe->u.hdr.rx_data, + precvframe->rx_data, pattrib->pkt_len, pattrib->MacIDValidEntry[0], pattrib->MacIDValidEntry[1] ); } else if (pattrib->pkt_rpt_type == HIS_REPORT) { - interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->u.hdr.rx_data); + interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->rx_data); } rtw_free_recvframe(precvframe, pfree_recv_queue); } diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index 691238078075..d76cc2db5028 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -28,18 +28,20 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void _rtw_free_recv_priv(struct recv_priv *precvpriv); -s32 rtw_recv_entry(union recv_frame *precv_frame); -int rtw_recv_indicatepkt(struct adapter *adapter, union recv_frame *recv_frame); +s32 rtw_recv_entry(struct recv_frame *precv_frame); +int rtw_recv_indicatepkt(struct adapter *adapter, + struct recv_frame *recv_frame); void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *retpkt); -void rtw_hostapd_mlme_rx(struct adapter *padapter, union recv_frame *recv_fr); +void rtw_hostapd_mlme_rx(struct adapter *padapter, struct recv_frame *recv_fr); void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void rtw_free_recv_priv(struct recv_priv *precvpriv); int rtw_os_recv_resource_init(struct recv_priv *recvpr, struct adapter *adapt); -int rtw_os_recv_resource_alloc(struct adapter *adapt, union recv_frame *recvfr); +int rtw_os_recv_resource_alloc(struct adapter *adapt, + struct recv_frame *recvfr); void rtw_os_recv_resource_free(struct recv_priv *precvpriv); int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h index a8facf00eac0..07e5f5227336 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h @@ -61,9 +61,10 @@ s32 rtl8188eu_init_recv_priv(struct adapter *padapter); void rtl8188eu_free_recv_priv(struct adapter *padapter); void rtl8188eu_recv_hdl(struct adapter *padapter, struct recv_buf *precvbuf); void rtl8188eu_recv_tasklet(void *priv); -void rtl8188e_query_rx_phy_status(union recv_frame *fr, struct phy_stat *phy); +void rtl8188e_query_rx_phy_status(struct recv_frame *fr, struct phy_stat *phy); void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe); -void update_recvframe_phyinfo_88e(union recv_frame *fra, struct phy_stat *phy); -void update_recvframe_attrib_88e(union recv_frame *fra, struct recv_stat *stat); +void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); +void update_recvframe_attrib_88e(struct recv_frame *fra, + struct recv_stat *stat); #endif diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index f0c982d6d5f2..09e2a3980ea7 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -236,13 +236,13 @@ enum SCAN_STATE { struct mlme_handler { unsigned int num; char *str; - unsigned int (*func)(struct adapter *adapt, union recv_frame *frame); + unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); }; struct action_handler { unsigned int num; char *str; - unsigned int (*func)(struct adapter *adapt, union recv_frame *frame); + unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); }; struct ss_res { @@ -490,7 +490,7 @@ 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, union recv_frame *precv_frame, +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); @@ -544,7 +544,8 @@ unsigned int is_ap_in_wep(struct adapter *padapter); unsigned int should_forbid_n_rate(struct adapter *padapter); void report_join_res(struct adapter *padapter, int res); -void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame); +void report_survey_event(struct adapter *padapter, + struct recv_frame *precv_frame); void report_surveydone_event(struct adapter *padapter); void report_del_sta_event(struct adapter *padapter, unsigned char *addr, unsigned short reason); @@ -609,46 +610,46 @@ void start_clnt_join(struct adapter *padapter); void start_create_ibss(struct adapter *padapter); unsigned int OnAssocReq(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAssocRsp(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnProbeReq(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnProbeRsp(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int DoReserved(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnBeacon(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAtim(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnDisassoc(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAuth(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAuthClient(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnDeAuth(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int on_action_spct(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_qos(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_dls(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_back(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int on_action_public(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_ht(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_wmm(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_p2p(struct adapter *padapter, - union recv_frame *precv_frame); + 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); diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index c6d7a659e9d1..e579c3827eee 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -270,7 +270,7 @@ struct recv_buf { len = (unsigned int )(tail - data); */ -struct recv_frame_hdr { +struct recv_frame { struct list_head list; struct sk_buff *pkt; struct sk_buff *pkt_newalloc; @@ -289,21 +289,16 @@ struct recv_frame_hdr { struct recv_reorder_ctrl *preorder_ctrl; }; -union recv_frame { - union { - struct recv_frame_hdr hdr; - } u; -}; - -union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); -union recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); -void rtw_init_recvframe(union recv_frame *precvframe, +struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv); -int rtw_free_recvframe(union recv_frame *precvframe, +int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue); #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue) -int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue); -int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue); +int _rtw_enqueue_recvframe(struct recv_frame *precvframe, + struct __queue *queue); +int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue); u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); @@ -313,29 +308,29 @@ struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue); void rtw_reordering_ctrl_timeout_handler(void *pcontext); -static inline u8 *get_rxmem(union recv_frame *precvframe) +static inline u8 *get_rxmem(struct recv_frame *precvframe) { /* always return rx_head... */ if (precvframe == NULL) return NULL; - return precvframe->u.hdr.rx_head; + return precvframe->rx_head; } -static inline u8 *get_rx_status(union recv_frame *precvframe) +static inline u8 *get_rx_status(struct recv_frame *precvframe) { return get_rxmem(precvframe); } -static inline u8 *get_recvframe_data(union recv_frame *precvframe) +static inline u8 *get_recvframe_data(struct recv_frame *precvframe) { /* always return rx_data */ if (precvframe == NULL) return NULL; - return precvframe->u.hdr.rx_data; + return precvframe->rx_data; } -static inline u8 *recvframe_push(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_push(struct recv_frame *precvframe, int sz) { /* append data before rx_data */ @@ -346,16 +341,16 @@ static inline u8 *recvframe_push(union recv_frame *precvframe, int sz) */ if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_data -= sz ; - if (precvframe->u.hdr.rx_data < precvframe->u.hdr.rx_head) { - precvframe->u.hdr.rx_data += sz; + precvframe->rx_data -= sz; + if (precvframe->rx_data < precvframe->rx_head) { + precvframe->rx_data += sz; return NULL; } - precvframe->u.hdr.len += sz; - return precvframe->u.hdr.rx_data; + precvframe->len += sz; + return precvframe->rx_data; } -static inline u8 *recvframe_pull(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ @@ -364,16 +359,16 @@ static inline u8 *recvframe_pull(union recv_frame *precvframe, int sz) if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_data += sz; - if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) { - precvframe->u.hdr.rx_data -= sz; + precvframe->rx_data += sz; + if (precvframe->rx_data > precvframe->rx_tail) { + precvframe->rx_data -= sz; return NULL; } - precvframe->u.hdr.len -= sz; - return precvframe->u.hdr.rx_data; + precvframe->len -= sz; + return precvframe->rx_data; } -static inline u8 *recvframe_put(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz) { /* used for append sz bytes from ptr to rx_tail, update rx_tail * and return the updated rx_tail to the caller */ @@ -382,17 +377,17 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, int sz) if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_tail += sz; + precvframe->rx_tail += sz; - if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) { - precvframe->u.hdr.rx_tail -= sz; + if (precvframe->rx_tail > precvframe->rx_end) { + precvframe->rx_tail -= sz; return NULL; } - precvframe->u.hdr.len += sz; - return precvframe->u.hdr.rx_tail; + precvframe->len += sz; + return precvframe->rx_tail; } -static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) { /* rmv data from rx_tail (by yitsen) */ @@ -402,16 +397,16 @@ static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, int sz) if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_tail -= sz; - if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) { - precvframe->u.hdr.rx_tail += sz; + precvframe->rx_tail -= sz; + if (precvframe->rx_tail < precvframe->rx_data) { + precvframe->rx_tail += sz; return NULL; } - precvframe->u.hdr.len -= sz; - return precvframe->u.hdr.rx_tail; + precvframe->len -= sz; + return precvframe->rx_tail; } -static inline unsigned char *get_rxbuf_desc(union recv_frame *precvframe) +static inline unsigned char *get_rxbuf_desc(struct recv_frame *precvframe) { unsigned char *buf_desc; @@ -420,20 +415,21 @@ static inline unsigned char *get_rxbuf_desc(union recv_frame *precvframe) return buf_desc; } -static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem) +static inline struct recv_frame *rxmem_to_recvframe(u8 *rxmem) { /* due to the design of 2048 bytes alignment of recv_frame, - * we can reference the union recv_frame */ + * we can reference the struct recv_frame */ /* from any given member of recv_frame. */ /* rxmem indicates the any member/address in recv_frame */ - return (union recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); + return (struct recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << + RXFRAME_ALIGN); } -static inline union recv_frame *pkt_to_recvframe(struct sk_buff *pkt) +static inline struct recv_frame *pkt_to_recvframe(struct sk_buff *pkt) { u8 *buf_star; - union recv_frame *precv_frame; + struct recv_frame *precv_frame; precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); return precv_frame; @@ -443,23 +439,23 @@ static inline u8 *pkt_to_recvmem(struct sk_buff *pkt) { /* return the rx_head */ - union recv_frame *precv_frame = pkt_to_recvframe(pkt); + struct recv_frame *precv_frame = pkt_to_recvframe(pkt); - return precv_frame->u.hdr.rx_head; + return precv_frame->rx_head; } static inline u8 *pkt_to_recvdata(struct sk_buff *pkt) { /* return the rx_data */ - union recv_frame *precv_frame = pkt_to_recvframe(pkt); + struct recv_frame *precv_frame = pkt_to_recvframe(pkt); - return precv_frame->u.hdr.rx_data; + return precv_frame->rx_data; } -static inline int get_recvframe_len(union recv_frame *precvframe) +static inline int get_recvframe_len(struct recv_frame *precvframe) { - return precvframe->u.hdr.len; + return precvframe->len; } static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) @@ -478,6 +474,6 @@ struct sta_info; void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); -void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame); +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame); #endif diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 3eff225a0e39..da397e4c6773 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -35,16 +35,16 @@ int rtw_os_recv_resource_init(struct recv_priv *precvpriv, return _SUCCESS; } -/* alloc os related resource in union recv_frame */ +/* alloc os related resource in struct recv_frame */ int rtw_os_recv_resource_alloc(struct adapter *padapter, - union recv_frame *precvframe) + struct recv_frame *precvframe) { - precvframe->u.hdr.pkt_newalloc = NULL; - precvframe->u.hdr.pkt = NULL; + precvframe->pkt_newalloc = NULL; + precvframe->pkt = NULL; return _SUCCESS; } -/* free os related resource in union recv_frame */ +/* free os related resource in struct recv_frame */ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) { } @@ -117,12 +117,12 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) } void rtw_hostapd_mlme_rx(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { } int rtw_recv_indicatepkt(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { struct recv_priv *precvpriv; struct __queue *pfree_recv_queue; @@ -133,7 +133,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, precvpriv = &(padapter->recvpriv); pfree_recv_queue = &(precvpriv->free_recv_queue); - skb = precv_frame->u.hdr.pkt; + skb = precv_frame->pkt; if (skb == NULL) { RT_TRACE(_module_recv_osdep_c_, _drv_err_, ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); @@ -143,18 +143,18 @@ int rtw_recv_indicatepkt(struct adapter *padapter, RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("rtw_recv_indicatepkt():skb != NULL !!!\n")); RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("rtw_recv_indicatepkt():precv_frame->u.hdr.rx_head =%p precv_frame->hdr.rx_data =%p\n", - precv_frame->u.hdr.rx_head, precv_frame->u.hdr.rx_data)); + ("rtw_recv_indicatepkt():precv_frame->rx_head =%p precv_frame->hdr.rx_data =%p\n", + precv_frame->rx_head, precv_frame->rx_data)); RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("precv_frame->hdr.rx_tail =%p precv_frame->u.hdr.rx_end =%p precv_frame->hdr.len =%d\n", - precv_frame->u.hdr.rx_tail, precv_frame->u.hdr.rx_end, - precv_frame->u.hdr.len)); + ("precv_frame->hdr.rx_tail =%p precv_frame->rx_end =%p precv_frame->hdr.len =%d\n", + precv_frame->rx_tail, precv_frame->rx_end, + precv_frame->len)); - skb->data = precv_frame->u.hdr.rx_data; + skb->data = precv_frame->rx_data; - skb_set_tail_pointer(skb, precv_frame->u.hdr.len); + skb_set_tail_pointer(skb, precv_frame->len); - skb->len = precv_frame->u.hdr.len; + skb->len = precv_frame->len; RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", @@ -165,7 +165,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sk_buff *pskb2 = NULL; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; int bmcast = IS_MCAST(pattrib->dst); if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), @@ -207,7 +207,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, _recv_indicatepkt_end: /* pointers to NULL before rtw_free_recvframe() */ - precv_frame->u.hdr.pkt = NULL; + precv_frame->pkt = NULL; rtw_free_recvframe(precv_frame, pfree_recv_queue); From ec612fe234a29f393592c7e07feeeab3ee2348d5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:08 -0600 Subject: [PATCH 0259/1375] staging: r8188eu: Remove pkt_to_recv{frame, data, mem} routines These functions are not called from the outside source. Suggested-by: Jes Sorensen Signed-off-by: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 38 -------------------- 1 file changed, 38 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index e579c3827eee..81fdcf568bb9 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -415,44 +415,6 @@ static inline unsigned char *get_rxbuf_desc(struct recv_frame *precvframe) return buf_desc; } -static inline struct recv_frame *rxmem_to_recvframe(u8 *rxmem) -{ - /* due to the design of 2048 bytes alignment of recv_frame, - * we can reference the struct recv_frame */ - /* from any given member of recv_frame. */ - /* rxmem indicates the any member/address in recv_frame */ - - return (struct recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << - RXFRAME_ALIGN); -} - -static inline struct recv_frame *pkt_to_recvframe(struct sk_buff *pkt) -{ - u8 *buf_star; - struct recv_frame *precv_frame; - precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); - - return precv_frame; -} - -static inline u8 *pkt_to_recvmem(struct sk_buff *pkt) -{ - /* return the rx_head */ - - struct recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->rx_head; -} - -static inline u8 *pkt_to_recvdata(struct sk_buff *pkt) -{ - /* return the rx_data */ - - struct recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->rx_data; -} - static inline int get_recvframe_len(struct recv_frame *precvframe) { return precvframe->len; From c1f7d570762df1dba1f8df5e1f12ae67726b5796 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:09 -0600 Subject: [PATCH 0260/1375] staging: r8188eu: Remove unused get_rxbuf_desc() Reported-by: Jes Sorensen Signed-off-by: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 81fdcf568bb9..21596398f172 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -406,15 +406,6 @@ static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) return precvframe->rx_tail; } -static inline unsigned char *get_rxbuf_desc(struct recv_frame *precvframe) -{ - unsigned char *buf_desc; - - if (precvframe == NULL) - return NULL; - return buf_desc; -} - static inline int get_recvframe_len(struct recv_frame *precvframe) { return precvframe->len; From c24e0ba3f2de42472e904259cf0d7839101f5c5b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:10 -0600 Subject: [PATCH 0261/1375] staging: r8188eu: Remove get_recvframe_len() This simple routine is replaced by a simple access of the len member. Reported-by: Jes Sorensen Signed-off-by: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- drivers/staging/rtl8188eu/include/rtw_recv.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 3333ae90f8bf..be0dfc169f1b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -743,7 +743,7 @@ static void count_rx_stats(struct adapter *padapter, struct rx_pkt_attrib *pattrib = &prframe->attrib; struct recv_priv *precvpriv = &padapter->recvpriv; - sz = get_recvframe_len(prframe); + sz = prframe->len; precvpriv->rx_bytes += sz; padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 21596398f172..1f4d98439df2 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -406,11 +406,6 @@ static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) return precvframe->rx_tail; } -static inline int get_recvframe_len(struct recv_frame *precvframe) -{ - return precvframe->len; -} - static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) { s32 power; /* in dBm. */ From bd86e98cb9422751563c0e1a05ce026ea89bc336 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:11 -0600 Subject: [PATCH 0262/1375] staging: r8188eu: Remove get_recvframe_data() This inline function checks that the pointer is not NULL and then returns the rx_data member. Unfortunately, all 3 callers of this function have dereferenced that pointer before this routine is called. As the check for NULL is useless, eliminate the routine. Reported-by: Jes Sorensen Signed-off-by: Larry Finger Cc: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 6 ++---- drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 2 +- drivers/staging/rtl8188eu/include/rtw_recv.h | 9 --------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index be0dfc169f1b..0c8b338dc6d3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -562,7 +562,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, auth_alg = adapter->securitypriv.dot11AuthAlgrthm; - ptr = get_recvframe_data(precv_frame); + ptr = precv_frame->rx_data; pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; @@ -1440,11 +1440,9 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) int ret = _SUCCESS; struct adapter *adapter = precvframe->adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ + u8 *ptr = precvframe->rx_data; struct rx_pkt_attrib *pattrib = &precvframe->attrib; - if (pattrib->encrypt) recvframe_pull_tail(precvframe, pattrib->icv_len); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c index f29bb79a757b..43eb960e4e0b 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -157,7 +157,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, pkt_info.bPacketToSelf = false; pkt_info.bPacketBeacon = false; - wlanhdr = get_recvframe_data(precvframe); + wlanhdr = precvframe->rx_data; pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && !pattrib->icv_err && !pattrib->crc_err && diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 1f4d98439df2..bcbce46cec85 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -321,15 +321,6 @@ static inline u8 *get_rx_status(struct recv_frame *precvframe) return get_rxmem(precvframe); } -static inline u8 *get_recvframe_data(struct recv_frame *precvframe) -{ - /* always return rx_data */ - if (precvframe == NULL) - return NULL; - - return precvframe->rx_data; -} - static inline u8 *recvframe_push(struct recv_frame *precvframe, int sz) { /* append data before rx_data */ From 88faf1b3bb38a2e67fd62e8c0d1ad5d6db3d6920 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:12 -0600 Subject: [PATCH 0263/1375] staging: r8188eu: Remove unused union Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_xmit.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index 1ac1dd31db68..62f5db169523 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -105,11 +105,6 @@ struct tx_desc { __le32 txdw7; }; -union txdesc { - struct tx_desc txdesc; - unsigned int value[TXDESC_SIZE>>2]; -}; - struct hw_xmit { struct __queue *sta_queue; int accnt; From 8117253c459650d68b1ac13b31aa76c45cde3e14 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:13 -0600 Subject: [PATCH 0264/1375] staging: r8188eu: Remove wrapper _exit_critical_mutex() This wrapper is a simple call to mutex_exit(). Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 2 +- drivers/staging/rtl8188eu/include/osdep_service.h | 7 ------- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index faeec73aec78..c197b228071d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -4438,7 +4438,7 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg } pxmitpriv->ack_tx = false; - _exit_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + mutex_unlock(&pxmitpriv->ack_tx_mutex); return ret; } diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index 1bfe497ebf4e..1fa5370f1da6 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -111,7 +111,7 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u break; } release_mutex: - _exit_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); + mutex_unlock(&dvobjpriv->usb_vendor_req_mutex); exit: return status; } diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 09e2d487df8c..5cf13a614e21 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -76,13 +76,6 @@ static inline int _enter_critical_mutex(struct mutex *pmutex, return ret; } - -static inline void _exit_critical_mutex(struct mutex *pmutex, - unsigned long *pirqL) -{ - mutex_unlock(pmutex); -} - static inline void rtw_list_delete(struct list_head *plist) { list_del_init(plist); diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index cf4107ab80cb..bc9ae1df7bd5 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1111,7 +1111,7 @@ int netdev_open(struct net_device *pnetdev) _enter_critical_mutex(padapter->hw_init_mutex, NULL); ret = _netdev_open(pnetdev); - _exit_critical_mutex(padapter->hw_init_mutex, NULL); + mutex_unlock(padapter->hw_init_mutex); return ret; } From 1781709bc3b69ed759165f2f59edf6bb6e48bfd1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:15 -0600 Subject: [PATCH 0265/1375] staging: r8188eu: Remove wrapper routine _init_workitem() This is simply another name for INIT_WORK(). Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/include/osdep_service.h | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index bc7873604a89..c0a0a521e591 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -84,7 +84,7 @@ int _rtw_init_evt_priv(struct evt_priv *pevtpriv) atomic_set(&pevtpriv->event_seq, 0); pevtpriv->evt_done_cnt = 0; - _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); + INIT_WORK(&pevtpriv->c2h_wk, c2h_wk_callback); pevtpriv->c2h_wk_alive = false; pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index afac53709843..b9c9fc09b7f0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -80,7 +80,7 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_8 _init_timer(&(pLed->BlinkTimer), padapter->pnetdev, BlinkTimerCallback, pLed); - _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed); + INIT_WORK(&(pLed->BlinkWorkItem), BlinkWorkItemCallback); } diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 5cf13a614e21..8f8596dee032 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -106,12 +106,6 @@ static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled) #define RTW_DECLARE_TIMER_HDL(name) \ void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS) -static inline void _init_workitem(struct work_struct *pwork, void *pfunc, - void *cntx) -{ - INIT_WORK(pwork, pfunc); -} - static inline void _set_workitem(struct work_struct *pwork) { schedule_work(pwork); From f87028f42fafe2ee9dc7f039b963173daae81123 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Feb 2014 16:54:16 -0600 Subject: [PATCH 0266/1375] staging: r8188eu: Remove wrapper routine _set_workitem() This is simply a wrapper around schedule_work(). Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/include/osdep_service.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index b9c9fc09b7f0..42b41ab1bce1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -34,7 +34,7 @@ void BlinkTimerCallback(void *data) if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - _set_workitem(&(pLed->BlinkWorkItem)); + schedule_work(&(pLed->BlinkWorkItem)); } /* */ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 8f8596dee032..5889f58ed7d3 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -106,11 +106,6 @@ static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled) #define RTW_DECLARE_TIMER_HDL(name) \ void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS) -static inline void _set_workitem(struct work_struct *pwork) -{ - schedule_work(pwork); -} - static inline void _cancel_workitem_sync(struct work_struct *pwork) { cancel_work_sync(pwork); From 60800abdc147ba034204408cc4745d66e1ffbb8e Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Fri, 14 Feb 2014 16:54:17 -0600 Subject: [PATCH 0267/1375] staging: r8188eu: Make firmware buffer persistent The present code reloads the firmware file from the disk every time the interface re-inits. Change to hold the firmware in memory, and only download to the device. Signed-off-by: Stas Sergeev Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 84 ++++++++++--------- drivers/staging/rtl8188eu/include/drv_types.h | 6 ++ .../staging/rtl8188eu/include/rtl8188e_hal.h | 11 --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 + 4 files changed, 56 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 13c06196073c..f9d5558431e0 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -584,6 +584,45 @@ static s32 _FWFreeToGo(struct adapter *padapter) #define IS_FW_81xxC(padapter) (((GET_HAL_DATA(padapter))->FirmwareSignature & 0xFFF0) == 0x88C0) +static int load_firmware(struct rt_firmware *pFirmware, struct device *device) +{ + int rtstatus = _SUCCESS; + const struct firmware *fw; + const char fw_name[] = "rtlwifi/rtl8188eufw.bin"; + + if (request_firmware(&fw, fw_name, device)) { + rtstatus = _FAIL; + goto exit; + } + if (!fw) { + pr_err("Firmware %s not available\n", fw_name); + rtstatus = _FAIL; + goto exit; + } + if (fw->size > FW_8188E_SIZE) { + rtstatus = _FAIL; + RT_TRACE(_module_hal_init_c_, _drv_err_, + ("Firmware size exceed 0x%X. Check it.\n", + FW_8188E_SIZE)); + goto exit; + } + + pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL); + if (!pFirmware->szFwBuffer) { + rtstatus = _FAIL; + goto exit; + } + memcpy(pFirmware->szFwBuffer, fw->data, fw->size); + pFirmware->ulFwLength = fw->size; + release_firmware(fw); + + DBG_88E_LEVEL(_drv_info_, + "+%s: !bUsedWoWLANFw, FmrmwareLen:%d+\n", __func__, + pFirmware->ulFwLength); +exit: + return rtstatus; +} + s32 rtl8188e_FirmwareDownload(struct adapter *padapter) { s32 rtStatus = _SUCCESS; @@ -592,51 +631,23 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter) struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); struct device *device = dvobj_to_dev(dvobj); - struct rt_firmware *pFirmware = NULL; - const struct firmware *fw; struct rt_firmware_hdr *pFwHdr = NULL; u8 *pFirmwareBuf; u32 FirmwareLen; - char fw_name[] = "rtlwifi/rtl8188eufw.bin"; static int log_version; RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__)); - pFirmware = (struct rt_firmware *)rtw_zmalloc(sizeof(struct rt_firmware)); - if (!pFirmware) { - rtStatus = _FAIL; + if (!dvobj->firmware.szFwBuffer) + rtStatus = load_firmware(&dvobj->firmware, device); + if (rtStatus == _FAIL) { + dvobj->firmware.szFwBuffer = NULL; goto Exit; } - - if (request_firmware(&fw, fw_name, device)) { - rtStatus = _FAIL; - goto Exit; - } - if (!fw) { - pr_err("Firmware %s not available\n", fw_name); - rtStatus = _FAIL; - goto Exit; - } - if (fw->size > FW_8188E_SIZE) { - rtStatus = _FAIL; - RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)); - goto Exit; - } - - pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL); - if (!pFirmware->szFwBuffer) { - rtStatus = _FAIL; - goto Exit; - } - memcpy(pFirmware->szFwBuffer, fw->data, fw->size); - pFirmware->ulFwLength = fw->size; - pFirmwareBuf = pFirmware->szFwBuffer; - FirmwareLen = pFirmware->ulFwLength; - release_firmware(fw); - - DBG_88E_LEVEL(_drv_info_, "+%s: !bUsedWoWLANFw, FmrmwareLen:%d+\n", __func__, FirmwareLen); + pFirmwareBuf = dvobj->firmware.szFwBuffer; + FirmwareLen = dvobj->firmware.ulFwLength; /* To Check Fw header. Added by tynli. 2009.12.04. */ - pFwHdr = (struct rt_firmware_hdr *)pFirmware->szFwBuffer; + pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.szFwBuffer; pHalData->FirmwareVersion = le16_to_cpu(pFwHdr->Version); pHalData->FirmwareSubVersion = pFwHdr->Subversion; @@ -688,10 +699,7 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter) goto Exit; } RT_TRACE(_module_hal_init_c_, _drv_info_, ("Firmware is ready to run!\n")); - kfree(pFirmware->szFwBuffer); Exit: - - kfree(pFirmware); return rtStatus; } diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h index a492a1c547ae..936c196699af 100644 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -159,9 +159,15 @@ struct registry_priv { #define MAX_CONTINUAL_URB_ERR 4 +struct rt_firmware { + u8 *szFwBuffer; + u32 ulFwLength; +}; + struct dvobj_priv { struct adapter *if1; struct adapter *if2; + struct rt_firmware firmware; /* For 92D, DMDP have 2 interface. */ u8 InterfaceNumber; diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 161f1e5af9e6..75e41c4aeb27 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -76,17 +76,6 @@ (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x2300 || \ (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88E0) -enum firmware_source { - FW_SOURCE_IMG_FILE = 0, - FW_SOURCE_HEADER_FILE = 1, /* from header file */ -}; - -struct rt_firmware { - enum firmware_source eFWSource; - u8 *szFwBuffer; - u32 ulFwLength; -}; - /* This structure must be careful with byte-ordering */ struct rt_firmware_hdr { diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index bc9ae1df7bd5..f123a930c012 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1204,6 +1204,7 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) int netdev_close(struct net_device *pnetdev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n")); @@ -1242,6 +1243,9 @@ int netdev_close(struct net_device *pnetdev) rtw_p2p_enable(padapter, P2P_ROLE_DISABLE); #endif /* CONFIG_88EU_P2P */ + kfree(dvobj->firmware.szFwBuffer); + dvobj->firmware.szFwBuffer = NULL; + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n")); DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup); return 0; From e6bed035ca652c43c897731366ea816ea2c4fbf1 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Fri, 14 Feb 2014 21:59:40 -0600 Subject: [PATCH 0268/1375] Staging: comedi: kcomedilib: replace deprecated simple_strtoul() with kstrtouint() Since simple_strtoul() has been deprecated, replace it with kstrtouint(). Also, since return code checking for this new function is enforced, add a check to ensure that the conversion has succeeded. Signed-off-by: Chase Southwood Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/kcomedilib/kcomedilib_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index 7dc5a18e69d4..8777f958c041 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -41,7 +41,8 @@ struct comedi_device *comedi_open(const char *filename) if (strncmp(filename, "/dev/comedi", 11) != 0) return NULL; - minor = simple_strtoul(filename + 11, NULL, 0); + if (kstrtouint(filename + 11, 0, &minor)) + return NULL; if (minor >= COMEDI_NUM_BOARD_MINORS) return NULL; From 630097f748cac22c75e43b89b90d2190b8e79fb8 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 16 Feb 2014 11:57:00 +0000 Subject: [PATCH 0269/1375] staging:iio:ad799x fix typo in copyright message Fix a typo in the copyright message. Signed-off-by: Hartmut Knaack Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad799x_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 9c8013c28824..9d3cf65ac90f 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -1,6 +1,6 @@ /* * iio/adc/ad799x.c - * Copyright (C) 2010-1011 Michael Hennerich, Analog Devices Inc. + * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. * * based on iio/adc/max1363 * Copyright (C) 2008-2010 Jonathan Cameron From 2deaf23b226ee3fe1ebda8fadf26855b88bf251f Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 16 Feb 2014 12:02:00 +0000 Subject: [PATCH 0270/1375] staging:iio:ad799x use regulator for vref Switch the ad799x driver to use the regulator framework and add binding for reference voltage. Signed-off-by: Hartmut Knaack Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad799x.h | 10 +-------- drivers/staging/iio/adc/ad799x_core.c | 32 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h index a591aa6feae1..fc8c85298feb 100644 --- a/drivers/staging/iio/adc/ad799x.h +++ b/drivers/staging/iio/adc/ad799x.h @@ -95,7 +95,7 @@ struct ad799x_state { struct i2c_client *client; const struct ad799x_chip_info *chip_info; struct regulator *reg; - u16 int_vref_mv; + struct regulator *vref; unsigned id; u16 config; @@ -103,14 +103,6 @@ struct ad799x_state { unsigned int transfer_size; }; -/* - * TODO: struct ad799x_platform_data needs to go into include/linux/iio - */ - -struct ad799x_platform_data { - u16 vref_mv; -}; - #ifdef CONFIG_AD799X_RING_BUFFER int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev); void ad799x_ring_cleanup(struct iio_dev *indio_dev); diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 9d3cf65ac90f..979ec77d6c2d 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -179,7 +179,10 @@ static int ad799x_read_raw(struct iio_dev *indio_dev, RES_MASK(chan->scan_type.realbits); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val = st->int_vref_mv; + ret = regulator_get_voltage(st->vref); + if (ret < 0) + return ret; + *val = ret / 1000; *val2 = chan->scan_type.realbits; return IIO_VAL_FRACTIONAL_LOG2; } @@ -533,7 +536,6 @@ static int ad799x_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; - struct ad799x_platform_data *pdata = client->dev.platform_data; struct ad799x_state *st; struct iio_dev *indio_dev; @@ -551,17 +553,21 @@ static int ad799x_probe(struct i2c_client *client, /* TODO: Add pdata options for filtering and bit delay */ - if (!pdata) - return -EINVAL; - - st->int_vref_mv = pdata->vref_mv; - st->reg = devm_regulator_get(&client->dev, "vcc"); - if (!IS_ERR(st->reg)) { - ret = regulator_enable(st->reg); - if (ret) - return ret; + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + ret = regulator_enable(st->reg); + if (ret) + return ret; + st->vref = devm_regulator_get(&client->dev, "vref"); + if (IS_ERR(st->vref)) { + ret = PTR_ERR(st->vref); + goto error_disable_reg; } + ret = regulator_enable(st->vref); + if (ret) + goto error_disable_reg; + st->client = client; indio_dev->dev.parent = &client->dev; @@ -597,6 +603,8 @@ static int ad799x_probe(struct i2c_client *client, error_cleanup_ring: ad799x_ring_cleanup(indio_dev); error_disable_reg: + if (!IS_ERR(st->vref)) + regulator_disable(st->vref); if (!IS_ERR(st->reg)) regulator_disable(st->reg); @@ -611,6 +619,8 @@ static int ad799x_remove(struct i2c_client *client) iio_device_unregister(indio_dev); ad799x_ring_cleanup(indio_dev); + if (!IS_ERR(st->vref)) + regulator_disable(st->vref); if (!IS_ERR(st->reg)) regulator_disable(st->reg); kfree(st->rx_buf); From b8a70aef04bf93ba0141008d284ffcdda5883093 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 16 Feb 2014 11:47:00 +0000 Subject: [PATCH 0271/1375] iio:max1363 fix typos of int_vref_mv This patch fixes some typos in max1363_chip_info_tbl[]. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1363.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index ce84b012f7df..9cf3229a7272 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1247,7 +1247,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { }, [max11604] = { .bits = 8, - .int_vref_mv = 4098, + .int_vref_mv = 4096, .mode_list = max1238_mode_list, .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, @@ -1307,7 +1307,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { }, [max11610] = { .bits = 10, - .int_vref_mv = 4098, + .int_vref_mv = 4096, .mode_list = max1238_mode_list, .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, @@ -1367,7 +1367,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { }, [max11616] = { .bits = 12, - .int_vref_mv = 4098, + .int_vref_mv = 4096, .mode_list = max1238_mode_list, .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, From 92825ff97411f0121166485798cdaf2deb6b5952 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 16 Feb 2014 11:53:00 +0000 Subject: [PATCH 0272/1375] iio get rid of unneccessary error_ret Get rid of obsolete uses of goto error_ret and some empty lines. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/buffer_cb.c | 7 ++----- drivers/iio/industrialio-buffer.c | 16 ++++++---------- drivers/iio/industrialio-core.c | 10 +++------- drivers/iio/industrialio-event.c | 17 ++++++----------- drivers/iio/industrialio-trigger.c | 11 ++++------- 5 files changed, 21 insertions(+), 40 deletions(-) diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c index 2d9c6f8c06db..eb46e728aa2e 100644 --- a/drivers/iio/buffer_cb.c +++ b/drivers/iio/buffer_cb.c @@ -46,10 +46,8 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, struct iio_channel *chan; cb_buff = kzalloc(sizeof(*cb_buff), GFP_KERNEL); - if (cb_buff == NULL) { - ret = -ENOMEM; - goto error_ret; - } + if (cb_buff == NULL) + return ERR_PTR(-ENOMEM); iio_buffer_init(&cb_buff->buffer); @@ -91,7 +89,6 @@ error_release_channels: iio_channel_release_all(cb_buff->channels); error_free_cb_buff: kfree(cb_buff); -error_ret: return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(iio_channel_get_all_cb); diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index c67d83bdc8f0..e108f2a9d827 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -264,7 +264,7 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev, &indio_dev->dev, &buffer->scan_el_dev_attr_list); if (ret) - goto error_ret; + return ret; attrcount++; ret = __iio_add_chan_devattr("type", chan, @@ -275,7 +275,7 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev, &indio_dev->dev, &buffer->scan_el_dev_attr_list); if (ret) - goto error_ret; + return ret; attrcount++; if (chan->type != IIO_TIMESTAMP) ret = __iio_add_chan_devattr("en", @@ -296,10 +296,9 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev, &indio_dev->dev, &buffer->scan_el_dev_attr_list); if (ret) - goto error_ret; + return ret; attrcount++; ret = attrcount; -error_ret: return ret; } @@ -553,13 +552,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) - goto error_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) - goto error_ret; + return ret; } } /* Keep a copy of current setup to allow roll back */ @@ -613,7 +612,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev, else { kfree(compound_mask); ret = -EINVAL; - goto error_ret; + return ret; } } } else { @@ -696,13 +695,10 @@ 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); indio_dev->active_scan_mask = old_mask; kfree(compound_mask); -error_ret: - return ret; } diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index acc911a836ca..a85b66081fae 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -692,10 +692,8 @@ int __iio_add_chan_devattr(const char *postfix, struct iio_dev_attr *iio_attr, *t; iio_attr = kzalloc(sizeof(*iio_attr), GFP_KERNEL); - if (iio_attr == NULL) { - ret = -ENOMEM; - goto error_ret; - } + if (iio_attr == NULL) + return -ENOMEM; ret = __iio_device_attr_init(&iio_attr->dev_attr, postfix, chan, readfunc, writefunc, shared_by); @@ -720,7 +718,6 @@ error_device_attr_deinit: __iio_device_attr_deinit(&iio_attr->dev_attr); error_iio_dev_attr_free: kfree(iio_attr); -error_ret: return ret; } @@ -1134,7 +1131,7 @@ int iio_device_register(struct iio_dev *indio_dev) if (ret) { dev_err(indio_dev->dev.parent, "Failed to register debugfs interfaces\n"); - goto error_ret; + return ret; } ret = iio_device_register_sysfs(indio_dev); if (ret) { @@ -1175,7 +1172,6 @@ error_free_sysfs: iio_device_unregister_sysfs(indio_dev); error_unreg_debugfs: iio_device_unregister_debugfs(indio_dev); -error_ret: return ret; } EXPORT_SYMBOL(iio_device_register); diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index c9c1419fe6e0..2e6f8e026fab 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -366,32 +366,31 @@ static int iio_device_add_event_sysfs(struct iio_dev *indio_dev, ret = iio_device_add_event(indio_dev, chan, i, type, dir, IIO_SEPARATE, &chan->event_spec[i].mask_separate); if (ret < 0) - goto error_ret; + return ret; attrcount += ret; ret = iio_device_add_event(indio_dev, chan, i, type, dir, IIO_SHARED_BY_TYPE, &chan->event_spec[i].mask_shared_by_type); if (ret < 0) - goto error_ret; + return ret; attrcount += ret; ret = iio_device_add_event(indio_dev, chan, i, type, dir, IIO_SHARED_BY_DIR, &chan->event_spec[i].mask_shared_by_dir); if (ret < 0) - goto error_ret; + return ret; attrcount += ret; ret = iio_device_add_event(indio_dev, chan, i, type, dir, IIO_SHARED_BY_ALL, &chan->event_spec[i].mask_shared_by_all); if (ret < 0) - goto error_ret; + return ret; attrcount += ret; } ret = attrcount; -error_ret: return ret; } @@ -440,10 +439,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) indio_dev->event_interface = kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL); - if (indio_dev->event_interface == NULL) { - ret = -ENOMEM; - goto error_ret; - } + if (indio_dev->event_interface == NULL) + return -ENOMEM; INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list); @@ -489,8 +486,6 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) error_free_setup_event_lines: iio_free_chan_devattr_list(&indio_dev->event_interface->dev_attr_list); kfree(indio_dev->event_interface); -error_ret: - return ret; } diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 766fab24b720..3383b025f62e 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -62,10 +62,9 @@ int iio_trigger_register(struct iio_trigger *trig_info) int ret; trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); - if (trig_info->id < 0) { - ret = trig_info->id; - goto error_ret; - } + if (trig_info->id < 0) + return trig_info->id; + /* Set the name used for the sysfs directory etc */ dev_set_name(&trig_info->dev, "trigger%ld", (unsigned long) trig_info->id); @@ -83,7 +82,6 @@ int iio_trigger_register(struct iio_trigger *trig_info) error_unregister_id: ida_simple_remove(&iio_trigger_ida, trig_info->id); -error_ret: return ret; } EXPORT_SYMBOL(iio_trigger_register); @@ -234,13 +232,12 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig, if (trig->ops && trig->ops->set_trigger_state && no_other_users) { ret = trig->ops->set_trigger_state(trig, false); if (ret) - goto error_ret; + return ret; } iio_trigger_put_irq(trig, pf->irq); free_irq(pf->irq, pf); module_put(pf->indio_dev->info->driver_module); -error_ret: return ret; } From 77bfa8baa0c230eb3d8acccd7d341f406a32cdf4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 14 Feb 2014 14:19:00 +0000 Subject: [PATCH 0273/1375] iio: Don't include extended name in shared attributes The extended name is channel specific and should not be included in shared attributes. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index a85b66081fae..39fb8cc46373 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -558,7 +558,7 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, ->channel2], postfix); } else { - if (chan->extend_name == NULL) + if (chan->extend_name == NULL || shared_by != IIO_SEPARATE) full_postfix = kstrdup(postfix, GFP_KERNEL); else full_postfix = kasprintf(GFP_KERNEL, From 7bbcf7e13695c70f13b2cae59392016c0fa2e7a6 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 14 Feb 2014 14:19:00 +0000 Subject: [PATCH 0274/1375] iio: Avoid unnecessary kasprintf name_format already contains the final name and no format characters. So the code basically reads: dev_attr->attr.name = kstrdup(GFP_KERNEL, name_format); if (dev_attr->attr.name == NULL) ... kfree(name_format); Which means we can save one alloc and free pair per attribute name if we directly assign name_format to dev_attr->attr.name. The patch also renames name_format to name to denote that this is indeed the final name and has no format characters in it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 39 +++++++++++---------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 39fb8cc46373..ede16aec20fb 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -540,7 +540,7 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, enum iio_shared_by shared_by) { int ret = 0; - char *name_format = NULL; + char *name = NULL; char *full_postfix; sysfs_attr_init(&dev_attr->attr); @@ -572,16 +572,15 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, if (chan->differential) { /* Differential can not have modifier */ switch (shared_by) { case IIO_SHARED_BY_ALL: - name_format = kasprintf(GFP_KERNEL, "%s", full_postfix); + name = kasprintf(GFP_KERNEL, "%s", full_postfix); break; case IIO_SHARED_BY_DIR: - name_format = kasprintf(GFP_KERNEL, "%s_%s", + name = kasprintf(GFP_KERNEL, "%s_%s", iio_direction[chan->output], full_postfix); break; case IIO_SHARED_BY_TYPE: - name_format - = kasprintf(GFP_KERNEL, "%s_%s-%s_%s", + name = kasprintf(GFP_KERNEL, "%s_%s-%s_%s", iio_direction[chan->output], iio_chan_type_name_spec[chan->type], iio_chan_type_name_spec[chan->type], @@ -593,8 +592,7 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, ret = -EINVAL; goto error_free_full_postfix; } - name_format - = kasprintf(GFP_KERNEL, + name = kasprintf(GFP_KERNEL, "%s_%s%d-%s%d_%s", iio_direction[chan->output], iio_chan_type_name_spec[chan->type], @@ -607,16 +605,15 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, } else { /* Single ended */ switch (shared_by) { case IIO_SHARED_BY_ALL: - name_format = kasprintf(GFP_KERNEL, "%s", full_postfix); + name = kasprintf(GFP_KERNEL, "%s", full_postfix); break; case IIO_SHARED_BY_DIR: - name_format = kasprintf(GFP_KERNEL, "%s_%s", + name = kasprintf(GFP_KERNEL, "%s_%s", iio_direction[chan->output], full_postfix); break; case IIO_SHARED_BY_TYPE: - name_format - = kasprintf(GFP_KERNEL, "%s_%s_%s", + name = kasprintf(GFP_KERNEL, "%s_%s_%s", iio_direction[chan->output], iio_chan_type_name_spec[chan->type], full_postfix); @@ -624,33 +621,24 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, case IIO_SEPARATE: if (chan->indexed) - name_format - = kasprintf(GFP_KERNEL, "%s_%s%d_%s", + name = kasprintf(GFP_KERNEL, "%s_%s%d_%s", iio_direction[chan->output], iio_chan_type_name_spec[chan->type], chan->channel, full_postfix); else - name_format - = kasprintf(GFP_KERNEL, "%s_%s_%s", + name = kasprintf(GFP_KERNEL, "%s_%s_%s", iio_direction[chan->output], iio_chan_type_name_spec[chan->type], full_postfix); break; } } - if (name_format == NULL) { + if (name == NULL) { ret = -ENOMEM; goto error_free_full_postfix; } - dev_attr->attr.name = kasprintf(GFP_KERNEL, - name_format, - chan->channel, - chan->channel2); - if (dev_attr->attr.name == NULL) { - ret = -ENOMEM; - goto error_free_name_format; - } + dev_attr->attr.name = name; if (readfunc) { dev_attr->attr.mode |= S_IRUGO; @@ -661,8 +649,7 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, dev_attr->attr.mode |= S_IWUSR; dev_attr->store = writefunc; } -error_free_name_format: - kfree(name_format); + error_free_full_postfix: kfree(full_postfix); From a0ad27765a5f4c9dc90fabe6a4b04a8656d7fae3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 15 Feb 2014 21:56:20 +0000 Subject: [PATCH 0275/1375] staging: vt6656: Replace typedef enum _CARD_OP_MODE Replace typedef enum _CARD_OP_MODE eOPMode with op_mode enum nl80211_iftype enum changes OP_MODE_INFRASTRUCTURE -> NL80211_IFTYPE_STATION OP_MODE_AP -> NL80211_IFTYPE_AP OP_MODE_DEF -> NL80211_IFTYPE_UNSPECIFIED OP_MODE_ADHOC -> NL80211_IFTYPE_ADHOC Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.h | 7 ------- drivers/staging/vt6656/device.h | 4 +++- drivers/staging/vt6656/dpc.c | 2 +- drivers/staging/vt6656/int.c | 4 ++-- drivers/staging/vt6656/iwctl.c | 2 +- drivers/staging/vt6656/main_usb.c | 2 +- drivers/staging/vt6656/power.c | 6 +++--- drivers/staging/vt6656/rxtx.c | 23 ++++++++++++----------- drivers/staging/vt6656/wmgr.c | 8 ++++---- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index c3017a74fa0f..f843e50875f9 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -39,13 +39,6 @@ typedef enum _CARD_PHY_TYPE { PHY_TYPE_11A } CARD_PHY_TYPE, *PCARD_PHY_TYPE; -typedef enum _CARD_OP_MODE { - OP_MODE_INFRASTRUCTURE = 0, - OP_MODE_ADHOC, - OP_MODE_AP, - OP_MODE_UNKNOWN -} CARD_OP_MODE, *PCARD_OP_MODE; - #define CB_MAX_CHANNEL_24G 14 #define CB_MAX_CHANNEL_5G 42 /* add channel9(5045MHz), 41==>42 */ #define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 1f422574c3d8..2bca7c0dedec 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -588,7 +588,9 @@ struct vnt_private { u16 wFragmentationThreshold; u8 byShortRetryLimit; u8 byLongRetryLimit; - CARD_OP_MODE eOPMode; + + enum nl80211_iftype op_mode; + int bBSSIDFilter; u16 wMaxTransmitMSDULifetime; u8 abyBSSID[ETH_ALEN]; diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index eca04c0c1d97..03351e741bd3 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -627,7 +627,7 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps if (pDevice->bDiversityEnable && (FrameSize>50) && - (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && + pDevice->op_mode == NL80211_IFTYPE_STATION && (pDevice->bLinkPass == true)) { BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0); } diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index e0e93869a681..d12036a9858a 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -131,7 +131,7 @@ void INTnsProcessData(struct vnt_private *pDevice) } if (pINTData->byISR0 != 0) { if (pINTData->byISR0 & ISR_BNTX) { - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->op_mode == NL80211_IFTYPE_AP) { if (pMgmt->byDTIMCount > 0) { pMgmt->byDTIMCount--; pMgmt->sNodeDBTable[0].bRxPSPoll = @@ -149,7 +149,7 @@ void INTnsProcessData(struct vnt_private *pDevice) bScheduleCommand((void *) pDevice, WLAN_CMD_BECON_SEND, NULL); - } /* if (pDevice->eOPMode == OP_MODE_AP) */ + } pDevice->bBeaconSent = true; } else { pDevice->bBeaconSent = false; diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 3a68dfa23d84..23320cca93d4 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -57,7 +57,7 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) struct vnt_private *pDevice = netdev_priv(dev); long ldBm; - pDevice->wstats.status = pDevice->eOPMode; + pDevice->wstats.status = pDevice->op_mode; RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); pDevice->wstats.qual.level = ldBm; pDevice->wstats.qual.noise = 0; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 664781c8c10f..4f913d322083 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -256,7 +256,7 @@ device_set_options(struct vnt_private *pDevice) { pDevice->byShortPreamble = PREAMBLE_TYPE_DEF; pDevice->ePSMode = PS_MODE_DEF; pDevice->b11hEnable = X80211h_MODE_DEF; - pDevice->eOPMode = OP_MODE_DEF; + pDevice->op_mode = NL80211_IFTYPE_UNSPECIFIED; pDevice->uConnectionRate = DATA_RATE_DEF; if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = true; pDevice->byBBType = BBP_TYPE_DEF; diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index e7d5487d1041..cd4f5bd2029f 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -67,7 +67,7 @@ void PSvEnablePowerSaving(struct vnt_private *pDevice, u16 wListenInterval) /* set period of power up before TBTT */ MACvWriteWord(pDevice, MAC_REG_PWBT, C_PWBT); - if (pDevice->eOPMode != OP_MODE_ADHOC) { + if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) { /* set AID */ MACvWriteWord(pDevice, MAC_REG_AIDATIM, wAID); } else { @@ -106,7 +106,7 @@ void PSvEnablePowerSaving(struct vnt_private *pDevice, u16 wListenInterval) pDevice->bEnablePSMode = true; /* We don't send null pkt in ad hoc mode since beacon will handle this. */ - if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) + if (pDevice->op_mode == NL80211_IFTYPE_STATION) PSbSendNullPacket(pDevice); pDevice->bPWBitOn = true; @@ -137,7 +137,7 @@ void PSvDisablePowerSaving(struct vnt_private *pDevice) MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN); pDevice->bEnablePSMode = false; - if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) + if (pDevice->op_mode == NL80211_IFTYPE_STATION) PSbSendNullPacket(pDevice); pDevice->bPWBitOn = false; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 51fff896fcb5..92146e503156 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -553,12 +553,13 @@ static int vnt_fill_ieee80211_rts(struct vnt_private *priv, rts->duration = duration; rts->frame_control = TYPE_CTL_RTS; - if (priv->eOPMode == OP_MODE_ADHOC || priv->eOPMode == OP_MODE_AP) + if (priv->op_mode == NL80211_IFTYPE_ADHOC || + priv->op_mode == NL80211_IFTYPE_AP) memcpy(rts->ra, eth_hdr->h_dest, ETH_ALEN); else memcpy(rts->ra, priv->abyBSSID, ETH_ALEN); - if (priv->eOPMode == OP_MODE_AP) + if (priv->op_mode == NL80211_IFTYPE_AP) memcpy(rts->ta, priv->abyBSSID, ETH_ALEN); else memcpy(rts->ta, eth_hdr->h_source, ETH_ALEN); @@ -991,8 +992,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, //Set packet type pTxBufHead->wFIFOCtl |= (u16)(byPktType<<8); - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { + if (pDevice->op_mode == NL80211_IFTYPE_ADHOC || + pDevice->op_mode == NL80211_IFTYPE_AP) { if (is_multicast_ether_addr(psEthHeader->h_dest)) { bNeedACK = false; pTxBufHead->wFIFOCtl = @@ -1292,7 +1293,7 @@ static void s_vGenerateMACHeader(struct vnt_private *pDevice, pMACHeader->frame_control = TYPE_802_11_DATA; - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->op_mode == NL80211_IFTYPE_AP) { memcpy(&(pMACHeader->addr1[0]), &(psEthHeader->h_dest[0]), ETH_ALEN); @@ -1302,7 +1303,7 @@ static void s_vGenerateMACHeader(struct vnt_private *pDevice, ETH_ALEN); pMACHeader->frame_control |= FC_FROMDS; } else { - if (pDevice->eOPMode == OP_MODE_ADHOC) { + if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { memcpy(&(pMACHeader->addr1[0]), &(psEthHeader->h_dest[0]), ETH_ALEN); @@ -1541,8 +1542,8 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pbyIVHead = (u8 *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); pbyPayloadHead = (u8 *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); do { - if ((pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && - (pDevice->bLinkPass == true)) { + if (pDevice->op_mode == NL80211_IFTYPE_STATION && + pDevice->bLinkPass == true) { pbyBSSID = pDevice->abyBSSID; // get pairwise key if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { @@ -1560,7 +1561,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pbyBSSID = pDevice->abyBroadcastAddr; if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { pTransmitKey = NULL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->eOPMode); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->op_mode); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); } @@ -2305,7 +2306,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } else { - if (pDevice->eOPMode == OP_MODE_ADHOC) { + if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { // Adhoc Tx rate decided from node DB if (is_multicast_ether_addr(pDevice->sTxEthHeader.h_dest)) { // Multicast use highest data rate @@ -2336,7 +2337,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } } - if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) { + if (pDevice->op_mode == NL80211_IFTYPE_STATION) { // Infra STA rate decided from AP Node, index = 0 pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate; } diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index d74b0e7cb171..0d69719a7426 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -2164,12 +2164,12 @@ void vMgrCreateOwnIBSS(struct vnt_private *pDevice, PCMD_STATUS pStatus) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); pMgmt->byDTIMPeriod = DEFAULT_DTIM_PERIOD; pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1; - pDevice->eOPMode = OP_MODE_AP; + pDevice->op_mode = NL80211_IFTYPE_AP; } if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1); - pDevice->eOPMode = OP_MODE_ADHOC; + pDevice->op_mode = NL80211_IFTYPE_ADHOC; } if (pDevice->bEncryptionEnable) { @@ -2359,7 +2359,7 @@ void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus) pMgmt->eCurrState = WMAC_STATE_JOINTED; // Adopt BSS state in Adapter Device Object - pDevice->eOPMode = OP_MODE_INFRASTRUCTURE; + pDevice->op_mode = NL80211_IFTYPE_STATION; memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); // Add current BSS to Candidate list @@ -2500,7 +2500,7 @@ void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus) pMgmt->eCurrMode = WMAC_MODE_IBSS_STA; pMgmt->eCurrState = WMAC_STATE_STARTED; // Adopt BSS state in Adapter Device Object - pDevice->eOPMode = OP_MODE_ADHOC; + pDevice->op_mode = NL80211_IFTYPE_ADHOC; pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); From bf1c820fcbdf3bb23c4846bdb48a191e710cb841 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 15 Feb 2014 21:58:55 +0000 Subject: [PATCH 0276/1375] staging: vt6656: remove typedef VIA_PKT_TYPE. The packet types PK_TYPE_11* are already defined in baseband.h as macros assign variable as u8 type. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 2bca7c0dedec..c195a9c8f1f1 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -221,15 +221,6 @@ typedef enum _VIA_BB_TYPE BB_TYPE_11G } VIA_BB_TYPE, *PVIA_BB_TYPE; -/* 0:11a, 1:11b, 2:11gb (only CCK in BasicRate), 3:11ga(OFDM in BasicRate) */ -typedef enum _VIA_PKT_TYPE -{ - PK_TYPE_11A = 0, - PK_TYPE_11B, - PK_TYPE_11GB, - PK_TYPE_11GA -} VIA_PKT_TYPE, *PVIA_PKT_TYPE; - /*++ NDIS related */ typedef enum __DEVICE_NDIS_STATUS { @@ -550,7 +541,7 @@ struct vnt_private { /* Rate */ VIA_BB_TYPE byBBType; /* 0: 11A, 1:11B, 2:11G */ - VIA_PKT_TYPE byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ + u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ u16 wBasicRate; u8 byACKRate; u8 byTopOFDMBasicRate; From a9052bc9b3bc7140325a5e936ede4e1f92037c1b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 15 Feb 2014 22:00:41 +0000 Subject: [PATCH 0277/1375] staging: vt6656: Remove typedef _VIA_BB_TYPE BB_TYPE_11* are already defined in baseband.h as macros. assign variable as u8 type. iwctl.c needs the baseband.h header for the macros. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 10 +--------- drivers/staging/vt6656/iwctl.c | 1 + 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index c195a9c8f1f1..ec20b14948df 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -213,14 +213,6 @@ typedef struct { bool bInUse; } INT_BUFFER, *PINT_BUFFER; -/* 0:11A 1:11B 2:11G */ -typedef enum _VIA_BB_TYPE -{ - BB_TYPE_11A = 0, - BB_TYPE_11B, - BB_TYPE_11G -} VIA_BB_TYPE, *PVIA_BB_TYPE; - /*++ NDIS related */ typedef enum __DEVICE_NDIS_STATUS { @@ -540,7 +532,7 @@ struct vnt_private { u8 byCWMaxMin; /* Rate */ - VIA_BB_TYPE byBBType; /* 0: 11A, 1:11B, 2:11G */ + u8 byBBType; /* 0: 11A, 1:11B, 2:11G */ u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ u16 wBasicRate; u8 byACKRate; diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 23320cca93d4..60264a655f24 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -41,6 +41,7 @@ #include "wpactl.h" #include "control.h" #include "rndis.h" +#include "baseband.h" static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, From dbb18cbb7eff574c9a8c83743d5904b4954f628e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 16 Feb 2014 19:08:21 +0000 Subject: [PATCH 0278/1375] staging: vt6656: int.h correct endian type Endian type u64 qwTSF Change to new base type __le64 tsf In INTnsProcessData use le64_to_cpu for qwCurrTSF. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/int.c | 2 +- drivers/staging/vt6656/int.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index d12036a9858a..22d1ef586e89 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -167,7 +167,7 @@ void INTnsProcessData(struct vnt_private *pDevice) NULL); } } - pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF); + pDevice->qwCurrTSF = le64_to_cpu(pINTData->tsf); /*DBG_PRN_GRP01(("ISR0 = %02x , LoTsf = %08x, HiTsf = %08x\n", diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h index 8e6e217ba4ff..7ce6efc7bfec 100644 --- a/drivers/staging/vt6656/int.h +++ b/drivers/staging/vt6656/int.h @@ -45,7 +45,7 @@ typedef struct tagSINTData { u8 byTSR3; u8 byPkt3; u16 wTime3; - u64 qwTSF; + __le64 tsf; u8 byISR0; u8 byISR1; u8 byRTSSuccess; From 864ace8ca7d2458881fcf86dce5af26dfbad3029 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 16 Feb 2014 19:09:20 +0000 Subject: [PATCH 0279/1375] staging: vt6656: int : Replace typedef struct tagSINTData. New struct vnt_interrupt_data removing the camel case from members. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/int.c | 48 +++++++++++++++++------------------- drivers/staging/vt6656/int.h | 43 ++++++++++++++++---------------- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index 22d1ef586e89..0094887d4d52 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -77,60 +77,58 @@ void INTvWorkItem(struct vnt_private *pDevice) void INTnsProcessData(struct vnt_private *pDevice) { - PSINTData pINTData; + struct vnt_interrupt_data *pINTData; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct net_device_stats *pStats = &pDevice->stats; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); - pINTData = (PSINTData) pDevice->intBuf.pDataBuf; - if (pINTData->byTSR0 & TSR_VALID) { - if (pINTData->byTSR0 & (TSR_TMO | TSR_RETRYTMO)) + pINTData = (struct vnt_interrupt_data *)pDevice->intBuf.pDataBuf; + if (pINTData->tsr0 & TSR_VALID) { + if (pINTData->tsr0 & (TSR_TMO | TSR_RETRYTMO)) pDevice->wstats.discard.retries++; else pStats->tx_packets++; BSSvUpdateNodeTxCounter(pDevice, - pINTData->byTSR0, - pINTData->byPkt0); - /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/ + pINTData->tsr0, + pINTData->pkt0); } - if (pINTData->byTSR1 & TSR_VALID) { - if (pINTData->byTSR1 & (TSR_TMO | TSR_RETRYTMO)) + if (pINTData->tsr1 & TSR_VALID) { + if (pINTData->tsr1 & (TSR_TMO | TSR_RETRYTMO)) pDevice->wstats.discard.retries++; else pStats->tx_packets++; BSSvUpdateNodeTxCounter(pDevice, - pINTData->byTSR1, - pINTData->byPkt1); - /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/ + pINTData->tsr1, + pINTData->pkt1); } - if (pINTData->byTSR2 & TSR_VALID) { - if (pINTData->byTSR2 & (TSR_TMO | TSR_RETRYTMO)) + if (pINTData->tsr2 & TSR_VALID) { + if (pINTData->tsr2 & (TSR_TMO | TSR_RETRYTMO)) pDevice->wstats.discard.retries++; else pStats->tx_packets++; BSSvUpdateNodeTxCounter(pDevice, - pINTData->byTSR2, - pINTData->byPkt2); + pINTData->tsr2, + pINTData->pkt2); /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/ } - if (pINTData->byTSR3 & TSR_VALID) { - if (pINTData->byTSR3 & (TSR_TMO | TSR_RETRYTMO)) + if (pINTData->tsr3 & TSR_VALID) { + if (pINTData->tsr3 & (TSR_TMO | TSR_RETRYTMO)) pDevice->wstats.discard.retries++; else pStats->tx_packets++; BSSvUpdateNodeTxCounter(pDevice, - pINTData->byTSR3, - pINTData->byPkt3); + pINTData->tsr3, + pINTData->pkt3); /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/ } - if (pINTData->byISR0 != 0) { - if (pINTData->byISR0 & ISR_BNTX) { + if (pINTData->isr0 != 0) { + if (pINTData->isr0 & ISR_BNTX) { if (pDevice->op_mode == NL80211_IFTYPE_AP) { if (pMgmt->byDTIMCount > 0) { pMgmt->byDTIMCount--; @@ -154,7 +152,7 @@ void INTnsProcessData(struct vnt_private *pDevice) } else { pDevice->bBeaconSent = false; } - if (pINTData->byISR0 & ISR_TBTT) { + if (pINTData->isr0 & ISR_TBTT) { if (pDevice->bEnablePSMode) bScheduleCommand((void *) pDevice, WLAN_CMD_TBTT_WAKEUP, @@ -175,8 +173,8 @@ void INTnsProcessData(struct vnt_private *pDevice) pINTData->dwLoTSF, pINTData->dwHiTSF)); */ } - if (pINTData->byISR1 != 0) - if (pINTData->byISR1 & ISR_GPIO3) + if (pINTData->isr1 != 0) + if (pINTData->isr1 & ISR_GPIO3) bScheduleCommand((void *) pDevice, WLAN_CMD_RADIO, NULL); diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h index 7ce6efc7bfec..08db868e1d07 100644 --- a/drivers/staging/vt6656/int.h +++ b/drivers/staging/vt6656/int.h @@ -32,29 +32,28 @@ #include "device.h" -typedef struct tagSINTData { - u8 byTSR0; - u8 byPkt0; - u16 wTime0; - u8 byTSR1; - u8 byPkt1; - u16 wTime1; - u8 byTSR2; - u8 byPkt2; - u16 wTime2; - u8 byTSR3; - u8 byPkt3; - u16 wTime3; +struct vnt_interrupt_data { + u8 tsr0; + u8 pkt0; + u16 time0; + u8 tsr1; + u8 pkt1; + u16 time1; + u8 tsr2; + u8 pkt2; + u16 time2; + u8 tsr3; + u8 pkt3; + u16 time3; __le64 tsf; - u8 byISR0; - u8 byISR1; - u8 byRTSSuccess; - u8 byRTSFail; - u8 byACKFail; - u8 byFCSErr; - u8 abySW[2]; -} __attribute__ ((__packed__)) -SINTData, *PSINTData; + u8 isr0; + u8 isr1; + u8 rts_success; + u8 rts_fail; + u8 ack_fail; + u8 fcs_err; + u8 sw[2]; +} __packed; void INTvWorkItem(struct vnt_private *); void INTnsProcessData(struct vnt_private *); From 210098a5e6bfc12bd014f768156b07f7005d4c9e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 16 Feb 2014 19:10:18 +0000 Subject: [PATCH 0280/1375] staging: vt6656: Clean up and remove camel case INTnsProcessData. Camel Case changes pDevice -> priv pINTData -> int_data pStats -> stats Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/int.c | 141 +++++++++++++++++------------------ 1 file changed, 70 insertions(+), 71 deletions(-) diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index 0094887d4d52..ec135b466ddd 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -75,112 +75,111 @@ void INTvWorkItem(struct vnt_private *pDevice) spin_unlock_irq(&pDevice->lock); } -void INTnsProcessData(struct vnt_private *pDevice) +void INTnsProcessData(struct vnt_private *priv) { - struct vnt_interrupt_data *pINTData; - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct net_device_stats *pStats = &pDevice->stats; + struct vnt_interrupt_data *int_data; + struct vnt_manager *mgmt = &priv->vnt_mgmt; + struct net_device_stats *stats = &priv->stats; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); - pINTData = (struct vnt_interrupt_data *)pDevice->intBuf.pDataBuf; - if (pINTData->tsr0 & TSR_VALID) { - if (pINTData->tsr0 & (TSR_TMO | TSR_RETRYTMO)) - pDevice->wstats.discard.retries++; + int_data = (struct vnt_interrupt_data *)priv->intBuf.pDataBuf; + + if (int_data->tsr0 & TSR_VALID) { + if (int_data->tsr0 & (TSR_TMO | TSR_RETRYTMO)) + priv->wstats.discard.retries++; else - pStats->tx_packets++; + stats->tx_packets++; - BSSvUpdateNodeTxCounter(pDevice, - pINTData->tsr0, - pINTData->pkt0); + BSSvUpdateNodeTxCounter(priv, + int_data->tsr0, + int_data->pkt0); } - if (pINTData->tsr1 & TSR_VALID) { - if (pINTData->tsr1 & (TSR_TMO | TSR_RETRYTMO)) - pDevice->wstats.discard.retries++; + + if (int_data->tsr1 & TSR_VALID) { + if (int_data->tsr1 & (TSR_TMO | TSR_RETRYTMO)) + priv->wstats.discard.retries++; else - pStats->tx_packets++; + stats->tx_packets++; - BSSvUpdateNodeTxCounter(pDevice, - pINTData->tsr1, - pINTData->pkt1); + BSSvUpdateNodeTxCounter(priv, + int_data->tsr1, + int_data->pkt1); } - if (pINTData->tsr2 & TSR_VALID) { - if (pINTData->tsr2 & (TSR_TMO | TSR_RETRYTMO)) - pDevice->wstats.discard.retries++; + + if (int_data->tsr2 & TSR_VALID) { + if (int_data->tsr2 & (TSR_TMO | TSR_RETRYTMO)) + priv->wstats.discard.retries++; else - pStats->tx_packets++; + stats->tx_packets++; - BSSvUpdateNodeTxCounter(pDevice, - pINTData->tsr2, - pINTData->pkt2); - /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/ + BSSvUpdateNodeTxCounter(priv, + int_data->tsr2, + int_data->pkt2); } - if (pINTData->tsr3 & TSR_VALID) { - if (pINTData->tsr3 & (TSR_TMO | TSR_RETRYTMO)) - pDevice->wstats.discard.retries++; + + if (int_data->tsr3 & TSR_VALID) { + if (int_data->tsr3 & (TSR_TMO | TSR_RETRYTMO)) + priv->wstats.discard.retries++; else - pStats->tx_packets++; + stats->tx_packets++; - BSSvUpdateNodeTxCounter(pDevice, - pINTData->tsr3, - pINTData->pkt3); - /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/ + BSSvUpdateNodeTxCounter(priv, + int_data->tsr3, + int_data->pkt3); } - if (pINTData->isr0 != 0) { - if (pINTData->isr0 & ISR_BNTX) { - if (pDevice->op_mode == NL80211_IFTYPE_AP) { - if (pMgmt->byDTIMCount > 0) { - pMgmt->byDTIMCount--; - pMgmt->sNodeDBTable[0].bRxPSPoll = + + if (int_data->isr0 != 0) { + if (int_data->isr0 & ISR_BNTX) { + if (priv->op_mode == NL80211_IFTYPE_AP) { + if (mgmt->byDTIMCount > 0) { + mgmt->byDTIMCount--; + mgmt->sNodeDBTable[0].bRxPSPoll = false; - } else if (pMgmt->byDTIMCount == 0) { + } else if (mgmt->byDTIMCount == 0) { /* check if multicast tx buffering */ - pMgmt->byDTIMCount = - pMgmt->byDTIMPeriod-1; - pMgmt->sNodeDBTable[0].bRxPSPoll = true; - if (pMgmt->sNodeDBTable[0].bPSEnable) - bScheduleCommand((void *) pDevice, + mgmt->byDTIMCount = + mgmt->byDTIMPeriod-1; + mgmt->sNodeDBTable[0].bRxPSPoll = true; + if (mgmt->sNodeDBTable[0].bPSEnable) + bScheduleCommand((void *) priv, WLAN_CMD_RX_PSPOLL, NULL); } - bScheduleCommand((void *) pDevice, + bScheduleCommand((void *) priv, WLAN_CMD_BECON_SEND, NULL); } - pDevice->bBeaconSent = true; + priv->bBeaconSent = true; } else { - pDevice->bBeaconSent = false; + priv->bBeaconSent = false; } - if (pINTData->isr0 & ISR_TBTT) { - if (pDevice->bEnablePSMode) - bScheduleCommand((void *) pDevice, + + if (int_data->isr0 & ISR_TBTT) { + if (priv->bEnablePSMode) + bScheduleCommand((void *) priv, WLAN_CMD_TBTT_WAKEUP, NULL); - if (pDevice->bChannelSwitch) { - pDevice->byChannelSwitchCount--; - if (pDevice->byChannelSwitchCount == 0) - bScheduleCommand((void *) pDevice, + if (priv->bChannelSwitch) { + priv->byChannelSwitchCount--; + if (priv->byChannelSwitchCount == 0) + bScheduleCommand((void *) priv, WLAN_CMD_11H_CHSW, NULL); } } - pDevice->qwCurrTSF = le64_to_cpu(pINTData->tsf); - /*DBG_PRN_GRP01(("ISR0 = %02x , - LoTsf = %08x, - HiTsf = %08x\n", - pINTData->byISR0, - pINTData->dwLoTSF, - pINTData->dwHiTSF)); */ + priv->qwCurrTSF = le64_to_cpu(int_data->tsf); } - if (pINTData->isr1 != 0) - if (pINTData->isr1 & ISR_GPIO3) - bScheduleCommand((void *) pDevice, + + if (int_data->isr1 != 0) + if (int_data->isr1 & ISR_GPIO3) + bScheduleCommand((void *) priv, WLAN_CMD_RADIO, NULL); - pDevice->intBuf.uDataLen = 0; - pDevice->intBuf.bInUse = false; + priv->intBuf.uDataLen = 0; + priv->intBuf.bInUse = false; - pStats->tx_errors = pDevice->wstats.discard.retries; - pStats->tx_dropped = pDevice->wstats.discard.retries; + stats->tx_errors = priv->wstats.discard.retries; + stats->tx_dropped = priv->wstats.discard.retries; } From 247b4b68b1cb65a2c2051f34415b455020fa8c10 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 17 Feb 2014 21:12:51 +0000 Subject: [PATCH 0281/1375] staging: vt6656: s_nsInterruptUsbIoCompleteRead set intBuf.bInUse to true intBuf.bInUse is set to false set back to true on successful usb_submit_urb Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 01cf09999b6d..258eec13b8df 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -400,9 +400,12 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) pDevice); ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); - if (ntStatus != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus); - } + if (ntStatus) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Submit int URB failed %d\n", ntStatus); + } else { + pDevice->intBuf.bInUse = true; + } } // // We return STATUS_MORE_PROCESSING_REQUIRED so that the completion From c98fbf9075e61a611edbb35475f2001197ca113e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 17 Feb 2014 21:16:20 +0000 Subject: [PATCH 0282/1375] staging: vt6656: s_nsInterruptUsbIoCompleteRead add urb status returns Drop out of urb return on usb errors and set intBuf.bInUse to false. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 258eec13b8df..d18cb2f0fb41 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -364,6 +364,19 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) // 4) The irp was cancelled. // 5) Some other failure from the USB device object. // + switch (urb->status) { + case 0: + case -ETIMEDOUT: + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + pDevice->intBuf.bInUse = false; + return; + default: + break; + } + ntStatus = urb->status; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsInterruptUsbIoCompleteRead Status %d\n", ntStatus); From def84bd9a11954d32d380c461eb884d1f0b2a8b7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 17 Feb 2014 21:18:40 +0000 Subject: [PATCH 0283/1375] staging: vt6656: s_nsInterruptUsbIoCompleteRead remove usb_fill_bulk_urb No need to fill urb in again, just resubmit it. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index d18cb2f0fb41..1ab1bbcc0fb0 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -404,14 +404,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) } if (pDevice->fKillEventPollingThread != true) { - usb_fill_bulk_urb(pDevice->pInterruptURB, - pDevice->usb, - usb_rcvbulkpipe(pDevice->usb, 1), - (void *) pDevice->intBuf.pDataBuf, - MAX_INTERRUPT_SIZE, - s_nsInterruptUsbIoCompleteRead, - pDevice); - ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); if (ntStatus) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO From 749627f2d85fec04c358496c5d5cb04cd73ace5a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 17 Feb 2014 21:24:33 +0000 Subject: [PATCH 0284/1375] staging: vt6656: Remove variable fKillEventPollingThread We already kill the urb and since patch s_nsInterruptUsbIoCompleteRead add urb status returns. have error handling There is no need for this variable. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/int.c | 5 +++-- drivers/staging/vt6656/main_usb.c | 2 -- drivers/staging/vt6656/usbpipe.c | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index ec20b14948df..e5f0be3b4ae4 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -421,7 +421,6 @@ struct vnt_private { /* Variables to track resources for the Interrupt In Pipe */ INT_BUFFER intBuf; - int fKillEventPollingThread; int bEventAvailable; /* default config from file by user setting */ diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index ec135b466ddd..34c45280a9c1 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -70,8 +70,9 @@ void INTvWorkItem(struct vnt_private *pDevice) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); spin_lock_irq(&pDevice->lock); - if (pDevice->fKillEventPollingThread != true) - ntStatus = PIPEnsInterruptRead(pDevice); + + ntStatus = PIPEnsInterruptRead(pDevice); + spin_unlock_irq(&pDevice->lock); } diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 4f913d322083..bea1ad93336a 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -1000,7 +1000,6 @@ static int device_open(struct net_device *dev) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; pDevice->bIsRxWorkItemQueued = true; - pDevice->fKillEventPollingThread = false; pDevice->bEventAvailable = false; pDevice->bWPADEVUp = false; @@ -1084,7 +1083,6 @@ static int device_close(struct net_device *dev) MP_SET_FLAG(pDevice, fMP_DISCONNECTED); MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES); MP_CLEAR_FLAG(pDevice, fMP_POST_READS); - pDevice->fKillEventPollingThread = true; cancel_delayed_work_sync(&pDevice->run_command_work); cancel_delayed_work_sync(&pDevice->second_callback_work); diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 1ab1bbcc0fb0..37219374329c 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -393,7 +393,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) // if (ntStatus == STATUS_NOT_CONNECTED ) // { - pDevice->fKillEventPollingThread = true; // } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"IntUSBIoCompleteControl STATUS = %d\n", ntStatus ); } else { @@ -403,7 +402,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) INTnsProcessData(pDevice); } - if (pDevice->fKillEventPollingThread != true) { ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); if (ntStatus) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO @@ -411,7 +409,7 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) } else { pDevice->intBuf.bInUse = true; } - } + // // We return STATUS_MORE_PROCESSING_REQUIRED so that the completion // routine (IofCompleteRequest) will stop working on the irp. From d9ad7a98c3411a559cba7f0301e865975d230560 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 17 Feb 2014 21:27:30 +0000 Subject: [PATCH 0285/1375] staging: vt6656: clean up s_nsInterruptUsbIoCompleteRead Remove comments, white space and camel case Camel Case changes pDevice -> priv ntStatus -> status Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 71 +++++++++++--------------------- 1 file changed, 25 insertions(+), 46 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 37219374329c..119f65603241 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -348,22 +348,12 @@ usb_fill_bulk_urb(pDevice->pInterruptURB, static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) { - struct vnt_private *pDevice = (struct vnt_private *)urb->context; - int ntStatus; + struct vnt_private *priv = (struct vnt_private *)urb->context; + int status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptUsbIoCompleteRead\n"); - // - // The context given to IoSetCompletionRoutine is the receive buffer object - // + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "---->s_nsInterruptUsbIoCompleteRead\n"); - // - // We have a number of cases: - // 1) The USB read timed out and we received no data. - // 2) The USB read timed out and we received some data. - // 3) The USB read was successful and fully filled our irp buffer. - // 4) The irp was cancelled. - // 5) Some other failure from the USB device object. - // switch (urb->status) { case 0: case -ETIMEDOUT: @@ -371,50 +361,39 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - pDevice->intBuf.bInUse = false; + priv->intBuf.bInUse = false; return; default: break; } - ntStatus = urb->status; + status = urb->status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsInterruptUsbIoCompleteRead Status %d\n", ntStatus); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "s_nsInterruptUsbIoCompleteRead Status %d\n", status); - // if we were not successful, we need to free the int buffer for future use right here - // otherwise interrupt data handler will free int buffer after it handle it. - if (( ntStatus != STATUS_SUCCESS )) { - pDevice->ulBulkInError++; - pDevice->intBuf.bInUse = false; + if (status != STATUS_SUCCESS) { + priv->ulBulkInError++; + priv->intBuf.bInUse = false; -// if (ntStatus == USBD_STATUS_CRC) { -// pDevice->ulIntInContCRCError++; -// } - -// if (ntStatus == STATUS_NOT_CONNECTED ) -// { -// } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"IntUSBIoCompleteControl STATUS = %d\n", ntStatus ); - } else { - pDevice->ulIntInBytesRead += (unsigned long) urb->actual_length; - pDevice->ulIntInContCRCError = 0; - pDevice->bEventAvailable = true; - INTnsProcessData(pDevice); - } - - ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); - if (ntStatus) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit int URB failed %d\n", ntStatus); + "IntUSBIoCompleteControl STATUS = %d\n", status); } else { - pDevice->intBuf.bInUse = true; + priv->ulIntInBytesRead += (unsigned long)urb->actual_length; + priv->ulIntInContCRCError = 0; + priv->bEventAvailable = true; + INTnsProcessData(priv); } - // - // We return STATUS_MORE_PROCESSING_REQUIRED so that the completion - // routine (IofCompleteRequest) will stop working on the irp. - // - return ; + status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); + if (status) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Submit int URB failed %d\n", status); + } else { + priv->intBuf.bInUse = true; + } + + return; } /* From a6b0961963955e575594d1150e24d1451817a334 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 17 Feb 2014 13:58:30 -0800 Subject: [PATCH 0286/1375] staging: android: Split uapi out of android_alarm.h Move the userspace interface of android_alarm.h to drivers/staging/android/uapi/android_alarm.h Cc: Greg KH Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Colin Cross [jstultz: minor commit msg tweak] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/android_alarm.h | 44 +------------- drivers/staging/android/uapi/android_alarm.h | 62 ++++++++++++++++++++ 2 files changed, 64 insertions(+), 42 deletions(-) create mode 100644 drivers/staging/android/uapi/android_alarm.h diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h index 4fd32f337f9c..495b20cf3bf6 100644 --- a/drivers/staging/android/android_alarm.h +++ b/drivers/staging/android/android_alarm.h @@ -16,50 +16,10 @@ #ifndef _LINUX_ANDROID_ALARM_H #define _LINUX_ANDROID_ALARM_H -#include -#include #include +#include -enum android_alarm_type { - /* return code bit numbers or set alarm arg */ - ANDROID_ALARM_RTC_WAKEUP, - ANDROID_ALARM_RTC, - ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, - ANDROID_ALARM_ELAPSED_REALTIME, - ANDROID_ALARM_SYSTEMTIME, - - ANDROID_ALARM_TYPE_COUNT, - - /* return code bit numbers */ - /* ANDROID_ALARM_TIME_CHANGE = 16 */ -}; - -enum android_alarm_return_flags { - ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP, - ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC, - ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = - 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, - ANDROID_ALARM_ELAPSED_REALTIME_MASK = - 1U << ANDROID_ALARM_ELAPSED_REALTIME, - ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, - ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16 -}; - -/* Disable alarm */ -#define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) - -/* Ack last alarm and wait for next */ -#define ANDROID_ALARM_WAIT _IO('a', 1) - -#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) -/* Set alarm */ -#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) -#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) -#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec) -#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) -#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) -#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) - +#include "uapi/android_alarm.h" #ifdef CONFIG_COMPAT #define ANDROID_ALARM_SET_COMPAT(type) ALARM_IOW(2, type, \ diff --git a/drivers/staging/android/uapi/android_alarm.h b/drivers/staging/android/uapi/android_alarm.h new file mode 100644 index 000000000000..aa013f6f5f3a --- /dev/null +++ b/drivers/staging/android/uapi/android_alarm.h @@ -0,0 +1,62 @@ +/* drivers/staging/android/uapi/android_alarm.h + * + * Copyright (C) 2006-2007 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _UAPI_LINUX_ANDROID_ALARM_H +#define _UAPI_LINUX_ANDROID_ALARM_H + +#include +#include + +enum android_alarm_type { + /* return code bit numbers or set alarm arg */ + ANDROID_ALARM_RTC_WAKEUP, + ANDROID_ALARM_RTC, + ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, + ANDROID_ALARM_ELAPSED_REALTIME, + ANDROID_ALARM_SYSTEMTIME, + + ANDROID_ALARM_TYPE_COUNT, + + /* return code bit numbers */ + /* ANDROID_ALARM_TIME_CHANGE = 16 */ +}; + +enum android_alarm_return_flags { + ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP, + ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC, + ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = + 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, + ANDROID_ALARM_ELAPSED_REALTIME_MASK = + 1U << ANDROID_ALARM_ELAPSED_REALTIME, + ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, + ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16 +}; + +/* Disable alarm */ +#define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) + +/* Ack last alarm and wait for next */ +#define ANDROID_ALARM_WAIT _IO('a', 1) + +#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) +/* Set alarm */ +#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) +#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) +#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec) +#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) +#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) +#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) + +#endif From fe8a78e4ba7946cf04c58c99d16c73af5884b8dd Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 17 Feb 2014 13:58:31 -0800 Subject: [PATCH 0287/1375] staging: android: Split uapi out of ashmem.h Move the userspace interface of ashmem.h to drivers/staging/android/uapi/ashmem.h Cc: Greg KH Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Colin Cross [jstultz: Minor commit message tweak] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.h | 30 +---------------- drivers/staging/android/uapi/ashmem.h | 47 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 drivers/staging/android/uapi/ashmem.h diff --git a/drivers/staging/android/ashmem.h b/drivers/staging/android/ashmem.h index 8dc0f0d3adf3..5abcfd7aa706 100644 --- a/drivers/staging/android/ashmem.h +++ b/drivers/staging/android/ashmem.h @@ -16,35 +16,7 @@ #include #include -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_PURGED 0 -#define ASHMEM_WAS_PURGED 1 - -/* Return values from ASHMEM_GET_PIN_STATUS: Is the mapping pinned? */ -#define ASHMEM_IS_UNPINNED 0 -#define ASHMEM_IS_PINNED 1 - -struct ashmem_pin { - __u32 offset; /* offset into region, in bytes, page-aligned */ - __u32 len; /* length forward from offset, in bytes, page-aligned */ -}; - -#define __ASHMEMIOC 0x77 - -#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) -#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN]) -#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) -#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) -#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long) -#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6) -#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin) -#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin) -#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9) -#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10) +#include "uapi/ashmem.h" /* support of 32bit userspace on 64bit platforms */ #ifdef CONFIG_COMPAT diff --git a/drivers/staging/android/uapi/ashmem.h b/drivers/staging/android/uapi/ashmem.h new file mode 100644 index 000000000000..ba4743c71d6b --- /dev/null +++ b/drivers/staging/android/uapi/ashmem.h @@ -0,0 +1,47 @@ +/* + * drivers/staging/android/uapi/ashmem.h + * + * Copyright 2008 Google Inc. + * Author: Robert Love + * + * This file is dual licensed. It may be redistributed and/or modified + * under the terms of the Apache 2.0 License OR version 2 of the GNU + * General Public License. + */ + +#ifndef _UAPI_LINUX_ASHMEM_H +#define _UAPI_LINUX_ASHMEM_H + +#include + +#define ASHMEM_NAME_LEN 256 + +#define ASHMEM_NAME_DEF "dev/ashmem" + +/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ +#define ASHMEM_NOT_PURGED 0 +#define ASHMEM_WAS_PURGED 1 + +/* Return values from ASHMEM_GET_PIN_STATUS: Is the mapping pinned? */ +#define ASHMEM_IS_UNPINNED 0 +#define ASHMEM_IS_PINNED 1 + +struct ashmem_pin { + __u32 offset; /* offset into region, in bytes, page-aligned */ + __u32 len; /* length forward from offset, in bytes, page-aligned */ +}; + +#define __ASHMEMIOC 0x77 + +#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) +#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN]) +#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) +#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) +#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long) +#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6) +#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin) +#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin) +#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9) +#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10) + +#endif /* _UAPI_LINUX_ASHMEM_H */ From 64907b94dab947f3f3fc96fe1ab810cbc12ca902 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 17 Feb 2014 13:58:32 -0800 Subject: [PATCH 0288/1375] staging: android: split uapi out of sync.h and sw_sync.h Move the userspace interfaces of sync.h and sw_sync.h to drivers/staging/android/uapi/ Cc: Greg KH Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Colin Cross [jstultz: Fixed up some conflicts from upstream spelling fixes] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.h | 20 +----- drivers/staging/android/sync.h | 86 +---------------------- drivers/staging/android/uapi/sw_sync.h | 32 +++++++++ drivers/staging/android/uapi/sync.h | 97 ++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 102 deletions(-) create mode 100644 drivers/staging/android/uapi/sw_sync.h create mode 100644 drivers/staging/android/uapi/sync.h diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h index 5aaf71d6974b..1a50669ec8a9 100644 --- a/drivers/staging/android/sw_sync.h +++ b/drivers/staging/android/sw_sync.h @@ -18,10 +18,9 @@ #define _LINUX_SW_SYNC_H #include - -#ifdef __KERNEL__ - +#include #include "sync.h" +#include "uapi/sw_sync.h" struct sw_sync_timeline { struct sync_timeline obj; @@ -57,19 +56,4 @@ static inline struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, } #endif /* IS_ENABLED(CONFIG_SW_SYNC) */ -#endif /* __KERNEL __ */ - -struct sw_sync_create_fence_data { - __u32 value; - char name[32]; - __s32 fence; /* fd of new fence */ -}; - -#define SW_SYNC_IOC_MAGIC 'W' - -#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ - struct sw_sync_create_fence_data) -#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) - - #endif /* _LINUX_SW_SYNC_H */ diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 6ee8d69c5c6d..eaf57cccf626 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -14,14 +14,14 @@ #define _LINUX_SYNC_H #include -#ifdef __KERNEL__ - #include #include #include #include #include +#include "uapi/sync.h" + struct sync_timeline; struct sync_pt; struct sync_fence; @@ -341,86 +341,4 @@ int sync_fence_cancel_async(struct sync_fence *fence, */ int sync_fence_wait(struct sync_fence *fence, long timeout); -#endif /* __KERNEL__ */ - -/** - * struct sync_merge_data - data passed to merge ioctl - * @fd2: file descriptor of second fence - * @name: name of new fence - * @fence: returns the fd of the new fence to userspace - */ -struct sync_merge_data { - __s32 fd2; /* fd of second fence */ - char name[32]; /* name of new fence */ - __s32 fence; /* fd on newly created fence */ -}; - -/** - * struct sync_pt_info - detailed sync_pt information - * @len: length of sync_pt_info including any driver_data - * @obj_name: name of parent sync_timeline - * @driver_name: name of driver implementing the parent - * @status: status of the sync_pt 0:active 1:signaled <0:error - * @timestamp_ns: timestamp of status change in nanoseconds - * @driver_data: any driver dependent data - */ -struct sync_pt_info { - __u32 len; - char obj_name[32]; - char driver_name[32]; - __s32 status; - __u64 timestamp_ns; - - __u8 driver_data[0]; -}; - -/** - * struct sync_fence_info_data - data returned from fence info ioctl - * @len: ioctl caller writes the size of the buffer its passing in. - * ioctl returns length of sync_fence_data returned to userspace - * including pt_info. - * @name: name of fence - * @status: status of fence. 1: signaled 0:active <0:error - * @pt_info: a sync_pt_info struct for every sync_pt in the fence - */ -struct sync_fence_info_data { - __u32 len; - char name[32]; - __s32 status; - - __u8 pt_info[0]; -}; - -#define SYNC_IOC_MAGIC '>' - -/** - * DOC: SYNC_IOC_WAIT - wait for a fence to signal - * - * pass timeout in milliseconds. Waits indefinitely timeout < 0. - */ -#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) - -/** - * DOC: SYNC_IOC_MERGE - merge two fences - * - * Takes a struct sync_merge_data. Creates a new fence containing copies of - * the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the - * new fence's fd in sync_merge_data.fence - */ -#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) - -/** - * DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence - * - * Takes a struct sync_fence_info_data with extra space allocated for pt_info. - * Caller should write the size of the buffer into len. On return, len is - * updated to reflect the total size of the sync_fence_info_data including - * pt_info. - * - * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence. - * To iterate over the sync_pt_infos, use the sync_pt_info.len field. - */ -#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\ - struct sync_fence_info_data) - #endif /* _LINUX_SYNC_H */ diff --git a/drivers/staging/android/uapi/sw_sync.h b/drivers/staging/android/uapi/sw_sync.h new file mode 100644 index 000000000000..9b5d4869505c --- /dev/null +++ b/drivers/staging/android/uapi/sw_sync.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _UAPI_LINUX_SW_SYNC_H +#define _UAPI_LINUX_SW_SYNC_H + +#include + +struct sw_sync_create_fence_data { + __u32 value; + char name[32]; + __s32 fence; /* fd of new fence */ +}; + +#define SW_SYNC_IOC_MAGIC 'W' + +#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ + struct sw_sync_create_fence_data) +#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) + +#endif /* _UAPI_LINUX_SW_SYNC_H */ diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h new file mode 100644 index 000000000000..e964c751f6b8 --- /dev/null +++ b/drivers/staging/android/uapi/sync.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2012 Google, Inc. + * + * 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 _UAPI_LINUX_SYNC_H +#define _UAPI_LINUX_SYNC_H + +#include +#include + +/** + * struct sync_merge_data - data passed to merge ioctl + * @fd2: file descriptor of second fence + * @name: name of new fence + * @fence: returns the fd of the new fence to userspace + */ +struct sync_merge_data { + __s32 fd2; /* fd of second fence */ + char name[32]; /* name of new fence */ + __s32 fence; /* fd on newly created fence */ +}; + +/** + * struct sync_pt_info - detailed sync_pt information + * @len: length of sync_pt_info including any driver_data + * @obj_name: name of parent sync_timeline + * @driver_name: name of driver implementing the parent + * @status: status of the sync_pt 0:active 1:signaled <0:error + * @timestamp_ns: timestamp of status change in nanoseconds + * @driver_data: any driver dependent data + */ +struct sync_pt_info { + __u32 len; + char obj_name[32]; + char driver_name[32]; + __s32 status; + __u64 timestamp_ns; + + __u8 driver_data[0]; +}; + +/** + * struct sync_fence_info_data - data returned from fence info ioctl + * @len: ioctl caller writes the size of the buffer its passing in. + * ioctl returns length of sync_fence_data returned to userspace + * including pt_info. + * @name: name of fence + * @status: status of fence. 1: signaled 0:active <0:error + * @pt_info: a sync_pt_info struct for every sync_pt in the fence + */ +struct sync_fence_info_data { + __u32 len; + char name[32]; + __s32 status; + + __u8 pt_info[0]; +}; + +#define SYNC_IOC_MAGIC '>' + +/** + * DOC: SYNC_IOC_WAIT - wait for a fence to signal + * + * pass timeout in milliseconds. Waits indefinitely timeout < 0. + */ +#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) + +/** + * DOC: SYNC_IOC_MERGE - merge two fences + * + * Takes a struct sync_merge_data. Creates a new fence containing copies of + * the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the + * new fence's fd in sync_merge_data.fence + */ +#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) + +/** + * DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence + * + * Takes a struct sync_fence_info_data with extra space allocated for pt_info. + * Caller should write the size of the buffer into len. On return, len is + * updated to reflect the total size of the sync_fence_info_data including + * pt_info. + * + * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence. + * To iterate over the sync_pt_infos, use the sync_pt_info.len field. + */ +#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\ + struct sync_fence_info_data) + +#endif /* _UAPI_LINUX_SYNC_H */ From a3e9ddb77e79198bd5114552675be02136e07059 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 17 Feb 2014 13:58:33 -0800 Subject: [PATCH 0289/1375] staging: android: Split uapi out of binder.h Move the userspace interface of binder.h to drivers/staging/android/uapi/binder.h. Cc: Greg KH Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Colin Cross [jstultz: Worked out the collisions from some of the type changes made upstream. Also minor commit subject tweak] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.h | 306 +----------------------- drivers/staging/android/uapi/binder.h | 330 ++++++++++++++++++++++++++ 2 files changed, 331 insertions(+), 305 deletions(-) create mode 100644 drivers/staging/android/uapi/binder.h diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index c4c1ed6964e4..d4101a671718 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -20,311 +20,7 @@ #ifndef _LINUX_BINDER_H #define _LINUX_BINDER_H -#include - -#define B_PACK_CHARS(c1, c2, c3, c4) \ - ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) -#define B_TYPE_LARGE 0x85 - -enum { - BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), - BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), - BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), - BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), - BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), -}; - -enum { - FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, - FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, -}; - -/* - * This is the flattened representation of a Binder object for transfer - * between processes. The 'offsets' supplied as part of a binder transaction - * contains offsets into the data where these structures occur. The Binder - * driver takes care of re-writing the structure type and data as it moves - * between processes. - */ -struct flat_binder_object { - /* 8 bytes for large_flat_header. */ - __u32 type; - __u32 flags; - - /* 8 bytes of data. */ - union { - void __user *binder; /* local object */ - __u32 handle; /* remote object */ - }; - - /* extra data associated with local object */ - void __user *cookie; -}; - -/* - * On 64-bit platforms where user code may run in 32-bits the driver must - * translate the buffer (and local binder) addresses appropriately. - */ - -struct binder_write_read { - size_t write_size; /* bytes to write */ - size_t write_consumed; /* bytes consumed by driver */ - unsigned long write_buffer; - size_t read_size; /* bytes to read */ - size_t read_consumed; /* bytes consumed by driver */ - unsigned long read_buffer; -}; - -/* Use with BINDER_VERSION, driver fills in fields. */ -struct binder_version { - /* driver protocol version -- increment with incompatible change */ - __s32 protocol_version; -}; - -/* This is the current protocol version. */ -#define BINDER_CURRENT_PROTOCOL_VERSION 7 - -#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) -#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) -#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) -#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) -#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) -#define BINDER_THREAD_EXIT _IOW('b', 8, __s32) -#define BINDER_VERSION _IOWR('b', 9, struct binder_version) - -/* - * NOTE: Two special error codes you should check for when calling - * in to the driver are: - * - * EINTR -- The operation has been interupted. This should be - * handled by retrying the ioctl() until a different error code - * is returned. - * - * ECONNREFUSED -- The driver is no longer accepting operations - * from your process. That is, the process is being destroyed. - * You should handle this by exiting from your process. Note - * that once this error code is returned, all further calls to - * the driver from any thread will return this same code. - */ - -enum transaction_flags { - TF_ONE_WAY = 0x01, /* this is a one-way call: async, no return */ - TF_ROOT_OBJECT = 0x04, /* contents are the component's root object */ - TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */ - TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */ -}; - -struct binder_transaction_data { - /* The first two are only used for bcTRANSACTION and brTRANSACTION, - * identifying the target and contents of the transaction. - */ - union { - __u32 handle; /* target descriptor of command transaction */ - void *ptr; /* target descriptor of return transaction */ - } target; - void *cookie; /* target object cookie */ - __u32 code; /* transaction command */ - - /* General information about the transaction. */ - __u32 flags; - pid_t sender_pid; - uid_t sender_euid; - size_t data_size; /* number of bytes of data */ - size_t offsets_size; /* number of bytes of offsets */ - - /* If this transaction is inline, the data immediately - * follows here; otherwise, it ends with a pointer to - * the data buffer. - */ - union { - struct { - /* transaction data */ - const void __user *buffer; - /* offsets from buffer to flat_binder_object structs */ - const void __user *offsets; - } ptr; - __u8 buf[8]; - } data; -}; - -struct binder_ptr_cookie { - void *ptr; - void *cookie; -}; - -struct binder_pri_desc { - __s32 priority; - __u32 desc; -}; - -struct binder_pri_ptr_cookie { - __s32 priority; - void *ptr; - void *cookie; -}; - -enum binder_driver_return_protocol { - BR_ERROR = _IOR('r', 0, __s32), - /* - * int: error code - */ - - BR_OK = _IO('r', 1), - /* No parameters! */ - - BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), - BR_REPLY = _IOR('r', 3, struct binder_transaction_data), - /* - * binder_transaction_data: the received command. - */ - - BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), - /* - * not currently supported - * int: 0 if the last bcATTEMPT_ACQUIRE was not successful. - * Else the remote object has acquired a primary reference. - */ - - BR_DEAD_REPLY = _IO('r', 5), - /* - * The target of the last transaction (either a bcTRANSACTION or - * a bcATTEMPT_ACQUIRE) is no longer with us. No parameters. - */ - - BR_TRANSACTION_COMPLETE = _IO('r', 6), - /* - * No parameters... always refers to the last transaction requested - * (including replies). Note that this will be sent even for - * asynchronous transactions. - */ - - BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), - BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), - BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), - BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie for binder - */ - - BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), - /* - * not currently supported - * int: priority - * void *: ptr to binder - * void *: cookie for binder - */ - - BR_NOOP = _IO('r', 12), - /* - * No parameters. Do nothing and examine the next command. It exists - * primarily so that we can replace it with a BR_SPAWN_LOOPER command. - */ - - BR_SPAWN_LOOPER = _IO('r', 13), - /* - * No parameters. The driver has determined that a process has no - * threads waiting to service incoming transactions. When a process - * receives this command, it must spawn a new service thread and - * register it via bcENTER_LOOPER. - */ - - BR_FINISHED = _IO('r', 14), - /* - * not currently supported - * stop threadpool thread - */ - - BR_DEAD_BINDER = _IOR('r', 15, void *), - /* - * void *: cookie - */ - BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, void *), - /* - * void *: cookie - */ - - BR_FAILED_REPLY = _IO('r', 17), - /* - * The the last transaction (either a bcTRANSACTION or - * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory). No parameters. - */ -}; - -enum binder_driver_command_protocol { - BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), - BC_REPLY = _IOW('c', 1, struct binder_transaction_data), - /* - * binder_transaction_data: the sent command. - */ - - BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), - /* - * not currently supported - * int: 0 if the last BR_ATTEMPT_ACQUIRE was not successful. - * Else you have acquired a primary reference on the object. - */ - - BC_FREE_BUFFER = _IOW('c', 3, void *), - /* - * void *: ptr to transaction data received on a read - */ - - BC_INCREFS = _IOW('c', 4, __u32), - BC_ACQUIRE = _IOW('c', 5, __u32), - BC_RELEASE = _IOW('c', 6, __u32), - BC_DECREFS = _IOW('c', 7, __u32), - /* - * int: descriptor - */ - - BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), - BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie for binder - */ - - BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), - /* - * not currently supported - * int: priority - * int: descriptor - */ - - BC_REGISTER_LOOPER = _IO('c', 11), - /* - * No parameters. - * Register a spawned looper thread with the device. - */ - - BC_ENTER_LOOPER = _IO('c', 12), - BC_EXIT_LOOPER = _IO('c', 13), - /* - * No parameters. - * These two commands are sent as an application-level thread - * enters and exits the binder loop, respectively. They are - * used so the binder can have an accurate count of the number - * of looping threads it has available. - */ - - BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie - */ - - BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie - */ - - BC_DEAD_BINDER_DONE = _IOW('c', 16, void *), - /* - * void *: cookie - */ -}; +#include "uapi/binder.h" #endif /* _LINUX_BINDER_H */ diff --git a/drivers/staging/android/uapi/binder.h b/drivers/staging/android/uapi/binder.h new file mode 100644 index 000000000000..2b1eb8106d58 --- /dev/null +++ b/drivers/staging/android/uapi/binder.h @@ -0,0 +1,330 @@ +/* + * Copyright (C) 2008 Google, Inc. + * + * Based on, but no longer compatible with, the original + * OpenBinder.org binder driver interface, which is: + * + * Copyright (c) 2005 Palmsource, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _UAPI_LINUX_BINDER_H +#define _UAPI_LINUX_BINDER_H + +#include + +#define B_PACK_CHARS(c1, c2, c3, c4) \ + ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) +#define B_TYPE_LARGE 0x85 + +enum { + BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), + BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), + BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), + BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), + BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), +}; + +enum { + FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, + FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, +}; + +/* + * This is the flattened representation of a Binder object for transfer + * between processes. The 'offsets' supplied as part of a binder transaction + * contains offsets into the data where these structures occur. The Binder + * driver takes care of re-writing the structure type and data as it moves + * between processes. + */ +struct flat_binder_object { + /* 8 bytes for large_flat_header. */ + __u32 type; + __u32 flags; + + /* 8 bytes of data. */ + union { + void __user *binder; /* local object */ + __u32 handle; /* remote object */ + }; + + /* extra data associated with local object */ + void __user *cookie; +}; + +/* + * On 64-bit platforms where user code may run in 32-bits the driver must + * translate the buffer (and local binder) addresses appropriately. + */ + +struct binder_write_read { + size_t write_size; /* bytes to write */ + size_t write_consumed; /* bytes consumed by driver */ + unsigned long write_buffer; + size_t read_size; /* bytes to read */ + size_t read_consumed; /* bytes consumed by driver */ + unsigned long read_buffer; +}; + +/* Use with BINDER_VERSION, driver fills in fields. */ +struct binder_version { + /* driver protocol version -- increment with incompatible change */ + __s32 protocol_version; +}; + +/* This is the current protocol version. */ +#define BINDER_CURRENT_PROTOCOL_VERSION 7 + +#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) +#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) +#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) +#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) +#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) +#define BINDER_THREAD_EXIT _IOW('b', 8, __s32) +#define BINDER_VERSION _IOWR('b', 9, struct binder_version) + +/* + * NOTE: Two special error codes you should check for when calling + * in to the driver are: + * + * EINTR -- The operation has been interupted. This should be + * handled by retrying the ioctl() until a different error code + * is returned. + * + * ECONNREFUSED -- The driver is no longer accepting operations + * from your process. That is, the process is being destroyed. + * You should handle this by exiting from your process. Note + * that once this error code is returned, all further calls to + * the driver from any thread will return this same code. + */ + +enum transaction_flags { + TF_ONE_WAY = 0x01, /* this is a one-way call: async, no return */ + TF_ROOT_OBJECT = 0x04, /* contents are the component's root object */ + TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */ + TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */ +}; + +struct binder_transaction_data { + /* The first two are only used for bcTRANSACTION and brTRANSACTION, + * identifying the target and contents of the transaction. + */ + union { + __u32 handle; /* target descriptor of command transaction */ + void *ptr; /* target descriptor of return transaction */ + } target; + void *cookie; /* target object cookie */ + __u32 code; /* transaction command */ + + /* General information about the transaction. */ + __u32 flags; + pid_t sender_pid; + uid_t sender_euid; + size_t data_size; /* number of bytes of data */ + size_t offsets_size; /* number of bytes of offsets */ + + /* If this transaction is inline, the data immediately + * follows here; otherwise, it ends with a pointer to + * the data buffer. + */ + union { + struct { + /* transaction data */ + const void __user *buffer; + /* offsets from buffer to flat_binder_object structs */ + const void __user *offsets; + } ptr; + __u8 buf[8]; + } data; +}; + +struct binder_ptr_cookie { + void *ptr; + void *cookie; +}; + +struct binder_pri_desc { + __s32 priority; + __u32 desc; +}; + +struct binder_pri_ptr_cookie { + __s32 priority; + void *ptr; + void *cookie; +}; + +enum binder_driver_return_protocol { + BR_ERROR = _IOR('r', 0, __s32), + /* + * int: error code + */ + + BR_OK = _IO('r', 1), + /* No parameters! */ + + BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), + BR_REPLY = _IOR('r', 3, struct binder_transaction_data), + /* + * binder_transaction_data: the received command. + */ + + BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), + /* + * not currently supported + * int: 0 if the last bcATTEMPT_ACQUIRE was not successful. + * Else the remote object has acquired a primary reference. + */ + + BR_DEAD_REPLY = _IO('r', 5), + /* + * The target of the last transaction (either a bcTRANSACTION or + * a bcATTEMPT_ACQUIRE) is no longer with us. No parameters. + */ + + BR_TRANSACTION_COMPLETE = _IO('r', 6), + /* + * No parameters... always refers to the last transaction requested + * (including replies). Note that this will be sent even for + * asynchronous transactions. + */ + + BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), + BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), + BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), + BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), + /* + * void *: ptr to binder + * void *: cookie for binder + */ + + BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), + /* + * not currently supported + * int: priority + * void *: ptr to binder + * void *: cookie for binder + */ + + BR_NOOP = _IO('r', 12), + /* + * No parameters. Do nothing and examine the next command. It exists + * primarily so that we can replace it with a BR_SPAWN_LOOPER command. + */ + + BR_SPAWN_LOOPER = _IO('r', 13), + /* + * No parameters. The driver has determined that a process has no + * threads waiting to service incoming transactions. When a process + * receives this command, it must spawn a new service thread and + * register it via bcENTER_LOOPER. + */ + + BR_FINISHED = _IO('r', 14), + /* + * not currently supported + * stop threadpool thread + */ + + BR_DEAD_BINDER = _IOR('r', 15, void *), + /* + * void *: cookie + */ + BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, void *), + /* + * void *: cookie + */ + + BR_FAILED_REPLY = _IO('r', 17), + /* + * The the last transaction (either a bcTRANSACTION or + * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory). No parameters. + */ +}; + +enum binder_driver_command_protocol { + BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), + BC_REPLY = _IOW('c', 1, struct binder_transaction_data), + /* + * binder_transaction_data: the sent command. + */ + + BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), + /* + * not currently supported + * int: 0 if the last BR_ATTEMPT_ACQUIRE was not successful. + * Else you have acquired a primary reference on the object. + */ + + BC_FREE_BUFFER = _IOW('c', 3, void *), + /* + * void *: ptr to transaction data received on a read + */ + + BC_INCREFS = _IOW('c', 4, __u32), + BC_ACQUIRE = _IOW('c', 5, __u32), + BC_RELEASE = _IOW('c', 6, __u32), + BC_DECREFS = _IOW('c', 7, __u32), + /* + * int: descriptor + */ + + BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), + BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), + /* + * void *: ptr to binder + * void *: cookie for binder + */ + + BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), + /* + * not currently supported + * int: priority + * int: descriptor + */ + + BC_REGISTER_LOOPER = _IO('c', 11), + /* + * No parameters. + * Register a spawned looper thread with the device. + */ + + BC_ENTER_LOOPER = _IO('c', 12), + BC_EXIT_LOOPER = _IO('c', 13), + /* + * No parameters. + * These two commands are sent as an application-level thread + * enters and exits the binder loop, respectively. They are + * used so the binder can have an accurate count of the number + * of looping threads it has available. + */ + + BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_ptr_cookie), + /* + * void *: ptr to binder + * void *: cookie + */ + + BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_ptr_cookie), + /* + * void *: ptr to binder + * void *: cookie + */ + + BC_DEAD_BINDER_DONE = _IOW('c', 16, void *), + /* + * void *: cookie + */ +}; + +#endif /* _UAPI_LINUX_BINDER_H */ + From b08585fb92a94eda82d868c4f9bf8ed653badbd0 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Mon, 17 Feb 2014 13:58:34 -0800 Subject: [PATCH 0290/1375] staging: ion: Create separate heap and client debugfs directories It can be slightly annoying to figure out which files under the ion debugfs directory are heap debug files and which ones are client debug files. Create separate subdirectories under ion to hold the different types of debug files. Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Mitchel Humpherys [jstultz: Minor commit subject tweaks] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 57 ++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 14cb6c6cb106..8f6bdb7dbf62 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -60,6 +60,8 @@ struct ion_device { unsigned long arg); struct rb_root clients; struct dentry *debug_root; + struct dentry *heaps_debug_root; + struct dentry *clients_debug_root; }; /** @@ -764,8 +766,15 @@ struct ion_client *ion_client_create(struct ion_device *dev, snprintf(debug_name, 64, "%u", client->pid); client->debug_root = debugfs_create_file(debug_name, 0664, - dev->debug_root, client, - &debug_client_fops); + dev->clients_debug_root, + client, &debug_client_fops); + if (!client->debug_root) { + char buf[256], *path; + path = dentry_path(dev->clients_debug_root, buf, 256); + pr_err("Failed to create client debugfs at %s/%s\n", + path, debug_name); + } + up_write(&dev->lock); return client; @@ -1442,6 +1451,8 @@ DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get, void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) { + struct dentry *debug_file; + if (!heap->ops->allocate || !heap->ops->free || !heap->ops->map_dma || !heap->ops->unmap_dma) pr_err("%s: can not add heap with invalid ops struct.\n", @@ -1456,15 +1467,31 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) the list later attempt higher id numbers first */ plist_node_init(&heap->node, -heap->id); plist_add(&heap->node, &dev->heaps); - debugfs_create_file(heap->name, 0664, dev->debug_root, heap, - &debug_heap_fops); + debug_file = debugfs_create_file(heap->name, 0664, + dev->heaps_debug_root, heap, + &debug_heap_fops); + + if (!debug_file) { + char buf[256], *path; + path = dentry_path(dev->heaps_debug_root, buf, 256); + pr_err("Failed to create heap debugfs at %s/%s\n", + path, heap->name); + } + #ifdef DEBUG_HEAP_SHRINKER if (heap->shrinker.shrink) { char debug_name[64]; snprintf(debug_name, 64, "%s_shrink", heap->name); - debugfs_create_file(debug_name, 0644, dev->debug_root, heap, - &debug_shrink_fops); + debug_file = debugfs_create_file( + debug_name, 0644, dev->heaps_debug_root, heap, + &debug_shrink_fops); + if (!debug_file) { + char buf[256], *path; + path = dentry_path(dev->heaps_debug_root, buf, 256); + pr_err("Failed to create heap shrinker debugfs at %s/%s\n", + path, debug_name); + } } #endif up_write(&dev->lock); @@ -1493,8 +1520,21 @@ struct ion_device *ion_device_create(long (*custom_ioctl) } idev->debug_root = debugfs_create_dir("ion", NULL); - if (!idev->debug_root) - pr_err("ion: failed to create debug files.\n"); + if (!idev->debug_root) { + pr_err("ion: failed to create debugfs root directory.\n"); + goto debugfs_done; + } + idev->heaps_debug_root = debugfs_create_dir("heaps", idev->debug_root); + if (!idev->heaps_debug_root) { + pr_err("ion: failed to create debugfs heaps directory.\n"); + goto debugfs_done; + } + idev->clients_debug_root = debugfs_create_dir("clients", + idev->debug_root); + if (!idev->clients_debug_root) + pr_err("ion: failed to create debugfs clients directory.\n"); + +debugfs_done: idev->custom_ioctl = custom_ioctl; idev->buffers = RB_ROOT; @@ -1508,6 +1548,7 @@ struct ion_device *ion_device_create(long (*custom_ioctl) void ion_device_destroy(struct ion_device *dev) { misc_deregister(&dev->dev); + debugfs_remove_recursive(dev->debug_root); /* XXX need to free the heaps and clients ? */ kfree(dev); } From 483ed03f5eee1d1207e8648e923d615ce0599814 Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Mon, 17 Feb 2014 13:58:35 -0800 Subject: [PATCH 0291/1375] staging: ion: Fix debugfs handling of multiple kernel clients Currently, Ion registers all debugfs entries for clients via pid. If there are multiple kernel clients, this means the debugfs entry only gets created for the first one. Fix this by creating debugfs entries by name always. When creating user clients, specify the name via the pid. Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Laura Abbott Signed-off-by: Mitchel Humpherys [jstultz: Minor commit subject tweaks] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 8f6bdb7dbf62..486942071f01 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -719,7 +719,6 @@ struct ion_client *ion_client_create(struct ion_device *dev, struct rb_node **p; struct rb_node *parent = NULL; struct ion_client *entry; - char debug_name[64]; pid_t pid; get_task_struct(current->group_leader); @@ -764,15 +763,14 @@ struct ion_client *ion_client_create(struct ion_device *dev, rb_link_node(&client->node, parent, p); rb_insert_color(&client->node, &dev->clients); - snprintf(debug_name, 64, "%u", client->pid); - client->debug_root = debugfs_create_file(debug_name, 0664, + client->debug_root = debugfs_create_file(name, 0664, dev->clients_debug_root, client, &debug_client_fops); if (!client->debug_root) { char buf[256], *path; path = dentry_path(dev->clients_debug_root, buf, 256); pr_err("Failed to create client debugfs at %s/%s\n", - path, debug_name); + path, name); } up_write(&dev->lock); @@ -1301,9 +1299,11 @@ static int ion_open(struct inode *inode, struct file *file) struct miscdevice *miscdev = file->private_data; struct ion_device *dev = container_of(miscdev, struct ion_device, dev); struct ion_client *client; + char debug_name[64]; pr_debug("%s: %d\n", __func__, __LINE__); - client = ion_client_create(dev, "user"); + snprintf(debug_name, 64, "%u", task_pid_nr(current->group_leader)); + client = ion_client_create(dev, debug_name); if (IS_ERR(client)) return PTR_ERR(client); file->private_data = client; From ae5cbf4a5a117549717d1da12ac1bd84f10dac59 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Mon, 17 Feb 2014 13:58:36 -0800 Subject: [PATCH 0292/1375] staging: ion: Store a copy of the client name on client creation Currently, we copy the pointer passed in to ion_client_create without making a copy of the string itself. This approach is problematic since it relies on the client keeping the name string in working order. Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Mitchel Humpherys [jstultz: Minor commit subject tweaks] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 486942071f01..eac4bce0894c 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -735,19 +735,18 @@ struct ion_client *ion_client_create(struct ion_device *dev, task_unlock(current->group_leader); client = kzalloc(sizeof(struct ion_client), GFP_KERNEL); - if (!client) { - if (task) - put_task_struct(current->group_leader); - return ERR_PTR(-ENOMEM); - } + if (!client) + goto err_put_task_struct; client->dev = dev; client->handles = RB_ROOT; idr_init(&client->idr); mutex_init(&client->lock); - client->name = name; client->task = task; client->pid = pid; + client->name = kstrdup(name, GFP_KERNEL); + if (!client->name) + goto err_free_client; down_write(&dev->lock); p = &dev->clients.rb_node; @@ -776,6 +775,13 @@ struct ion_client *ion_client_create(struct ion_device *dev, up_write(&dev->lock); return client; + +err_free_client: + kfree(client); +err_put_task_struct: + if (task) + put_task_struct(current->group_leader); + return ERR_PTR(-ENOMEM); } EXPORT_SYMBOL(ion_client_create); @@ -800,6 +806,7 @@ void ion_client_destroy(struct ion_client *client) debugfs_remove_recursive(client->debug_root); up_write(&dev->lock); + kfree(client->name); kfree(client); } EXPORT_SYMBOL(ion_client_destroy); From 2803ac7bf20129365ff7b774adf63e0fd35c4221 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Mon, 17 Feb 2014 13:58:37 -0800 Subject: [PATCH 0293/1375] staging: ion: Make sure all clients are exposed in debugfs Currently, if multiple Ion clients are created with the same name, only the first one shows up in debugfs. Rectify this by adding a monotonically-increasing serial number to the debug names of Ion clients. Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Mitchel Humpherys [jstultz: Minor commit subject tweaks] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 38 +++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index eac4bce0894c..577669789de1 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -72,6 +72,8 @@ struct ion_device { * @idr: an idr space for allocating handle ids * @lock: lock protecting the tree of handles * @name: used for debugging + * @display_name: used for debugging (unique version of @name) + * @display_serial: used for debugging (to make display_name unique) * @task: used for debugging * * A client represents a list of buffers this client may access. @@ -85,6 +87,8 @@ struct ion_client { struct idr idr; struct mutex lock; const char *name; + char *display_name; + int display_serial; struct task_struct *task; pid_t pid; struct dentry *debug_root; @@ -711,6 +715,21 @@ static const struct file_operations debug_client_fops = { .release = single_release, }; +static int ion_get_client_serial(const struct rb_root *root, + const unsigned char *name) +{ + int serial = -1; + struct rb_node *node; + for (node = rb_first(root); node; node = rb_next(node)) { + struct ion_client *client = rb_entry(node, struct ion_client, + node); + if (strcmp(client->name, name)) + continue; + serial = max(serial, client->display_serial); + } + return serial + 1; +} + struct ion_client *ion_client_create(struct ion_device *dev, const char *name) { @@ -721,6 +740,11 @@ struct ion_client *ion_client_create(struct ion_device *dev, struct ion_client *entry; pid_t pid; + if (!name) { + pr_err("%s: Name cannot be null\n", __func__); + return ERR_PTR(-EINVAL); + } + get_task_struct(current->group_leader); task_lock(current->group_leader); pid = task_pid_nr(current->group_leader); @@ -749,6 +773,13 @@ struct ion_client *ion_client_create(struct ion_device *dev, goto err_free_client; down_write(&dev->lock); + client->display_serial = ion_get_client_serial(&dev->clients, name); + client->display_name = kasprintf( + GFP_KERNEL, "%s-%d", name, client->display_serial); + if (!client->display_name) { + up_write(&dev->lock); + goto err_free_client_name; + } p = &dev->clients.rb_node; while (*p) { parent = *p; @@ -762,20 +793,22 @@ struct ion_client *ion_client_create(struct ion_device *dev, rb_link_node(&client->node, parent, p); rb_insert_color(&client->node, &dev->clients); - client->debug_root = debugfs_create_file(name, 0664, + client->debug_root = debugfs_create_file(client->display_name, 0664, dev->clients_debug_root, client, &debug_client_fops); if (!client->debug_root) { char buf[256], *path; path = dentry_path(dev->clients_debug_root, buf, 256); pr_err("Failed to create client debugfs at %s/%s\n", - path, name); + path, client->display_name); } up_write(&dev->lock); return client; +err_free_client_name: + kfree(client->name); err_free_client: kfree(client); err_put_task_struct: @@ -806,6 +839,7 @@ void ion_client_destroy(struct ion_client *client) debugfs_remove_recursive(client->debug_root); up_write(&dev->lock); + kfree(client->display_name); kfree(client->name); kfree(client); } From b9daf0b60b8a6a5151fca0e8cbb2dab763a3e92a Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 17 Feb 2014 13:58:38 -0800 Subject: [PATCH 0294/1375] staging: ion: Move shrinker out of heaps Every heap that uses deferred frees is going to need a shrinker to shrink the freelist under memory pressure. Rather than requiring each heap to implement a shrinker, automatically register a shrinker if the deferred free flag is set. The system heap also needs to shrink its page pools, so add a shrink function to the heap ops that will be called after shrinking the freelists. Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Colin Cross [jstultz: Resolved big conflicts with the shrinker api change. Also minor commit subject tweak.] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 3 + drivers/staging/android/ion/ion_heap.c | 50 +++++++++++ drivers/staging/android/ion/ion_page_pool.c | 8 +- drivers/staging/android/ion/ion_priv.h | 21 +++-- drivers/staging/android/ion/ion_system_heap.c | 82 ++++--------------- 5 files changed, 86 insertions(+), 78 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 577669789de1..08367179a48c 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1502,6 +1502,9 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) ion_heap_init_deferred_free(heap); + if ((heap->flags & ION_HEAP_FLAG_DEFER_FREE) || heap->ops->shrink) + ion_heap_init_shrinker(heap); + heap->dev = dev; down_write(&dev->lock); /* use negative heap->id to reverse the priority -- when traversing diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index 305b75ed6385..49ace13ac545 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c @@ -252,6 +252,56 @@ int ion_heap_init_deferred_free(struct ion_heap *heap) return 0; } +static unsigned long ion_heap_shrink_count(struct shrinker *shrinker, + struct shrink_control *sc) +{ + struct ion_heap *heap = container_of(shrinker, struct ion_heap, + shrinker); + int total = 0; + + total = ion_heap_freelist_size(heap) / PAGE_SIZE; + if (heap->ops->shrink) + total += heap->ops->shrink(heap, sc->gfp_mask, 0); + return total; +} + +static unsigned long ion_heap_shrink_scan(struct shrinker *shrinker, + struct shrink_control *sc) +{ + struct ion_heap *heap = container_of(shrinker, struct ion_heap, + shrinker); + int freed = 0; + int to_scan = sc->nr_to_scan; + + if (to_scan == 0) + return 0; + + /* + * shrink the free list first, no point in zeroing the memory if we're + * just going to reclaim it + */ + if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) + freed = ion_heap_freelist_drain(heap, to_scan * PAGE_SIZE) / + PAGE_SIZE; + + to_scan -= freed; + if (to_scan <= 0) + return freed; + + if (heap->ops->shrink) + freed += heap->ops->shrink(heap, sc->gfp_mask, to_scan); + return freed; +} + +void ion_heap_init_shrinker(struct ion_heap *heap) +{ + heap->shrinker.count_objects = ion_heap_shrink_count; + heap->shrinker.scan_objects = ion_heap_shrink_scan; + heap->shrinker.seeks = DEFAULT_SEEKS; + heap->shrinker.batch = 0; + register_shrinker(&heap->shrinker); +} + struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data) { struct ion_heap *heap = NULL; diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index fa693c23681a..ecb5fc34ec5c 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -130,8 +130,7 @@ static int ion_page_pool_total(struct ion_page_pool *pool, bool high) int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, int nr_to_scan) { - int nr_freed = 0; - int i; + int freed; bool high; high = !!(gfp_mask & __GFP_HIGHMEM); @@ -139,7 +138,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, if (nr_to_scan == 0) return ion_page_pool_total(pool, high); - for (i = 0; i < nr_to_scan; i++) { + for (freed = 0; freed < nr_to_scan; freed++) { struct page *page; mutex_lock(&pool->mutex); @@ -153,10 +152,9 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, } mutex_unlock(&pool->mutex); ion_page_pool_free_pages(pool, page); - nr_freed += (1 << pool->order); } - return nr_freed; + return freed; } struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order) diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 0942a7fc82b4..bcf9d19b57a3 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -114,6 +114,7 @@ struct ion_heap_ops { void (*unmap_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); int (*map_user)(struct ion_heap *mapper, struct ion_buffer *buffer, struct vm_area_struct *vma); + int (*shrink)(struct ion_heap *heap, gfp_t gfp_mask, int nr_to_scan); }; /** @@ -132,10 +133,7 @@ struct ion_heap_ops { * allocating. These are specified by platform data and * MUST be unique * @name: used for debugging - * @shrinker: a shrinker for the heap, if the heap caches system - * memory, it must define a shrinker to return it on low - * memory conditions, this includes system memory cached - * in the deferred free lists for heaps that support it + * @shrinker: a shrinker for the heap * @free_list: free list head if deferred free is used * @free_list_size size of the deferred free list in bytes * @lock: protects the free list @@ -218,6 +216,16 @@ int ion_heap_map_user(struct ion_heap *, struct ion_buffer *, int ion_heap_buffer_zero(struct ion_buffer *buffer); int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot); +/** + * ion_heap_init_shrinker + * @heap: the heap + * + * If a heap sets the ION_HEAP_FLAG_DEFER_FREE flag or defines the shrink op + * this function will be called to setup a shrinker to shrink the freelists + * and call the heap's shrink op. + */ +void ion_heap_init_shrinker(struct ion_heap *heap); + /** * ion_heap_init_deferred_free -- initialize deferred free functionality * @heap: the heap @@ -305,13 +313,8 @@ void ion_carveout_free(struct ion_heap *heap, ion_phys_addr_t addr, * @low_count: number of lowmem items in the pool * @high_items: list of highmem items * @low_items: list of lowmem items - * @shrinker: a shrinker for the items * @mutex: lock protecting this struct and especially the count * item list - * @alloc: function to be used to allocate pageory when the pool - * is empty - * @free: function to be used to free pageory back to the system - * when the shrinker fires * @gfp_mask: gfp_mask to use from alloc * @order: order of pages in the pool * @list: plist node for list of pools diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 9849f3963e75..f453d977c80c 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -231,6 +231,23 @@ static void ion_system_heap_unmap_dma(struct ion_heap *heap, return; } +static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask, + int nr_to_scan) +{ + struct ion_system_heap *sys_heap; + int nr_total = 0; + int i; + + sys_heap = container_of(heap, struct ion_system_heap, heap); + + for (i = 0; i < num_orders; i++) { + struct ion_page_pool *pool = sys_heap->pools[i]; + nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan); + } + + return nr_total; +} + static struct ion_heap_ops system_heap_ops = { .allocate = ion_system_heap_allocate, .free = ion_system_heap_free, @@ -239,67 +256,9 @@ static struct ion_heap_ops system_heap_ops = { .map_kernel = ion_heap_map_kernel, .unmap_kernel = ion_heap_unmap_kernel, .map_user = ion_heap_map_user, + .shrink = ion_system_heap_shrink, }; -static unsigned long ion_system_heap_shrink_count(struct shrinker *shrinker, - struct shrink_control *sc) -{ - struct ion_heap *heap = container_of(shrinker, struct ion_heap, - shrinker); - struct ion_system_heap *sys_heap = container_of(heap, - struct ion_system_heap, - heap); - int nr_total = 0; - int i; - - /* total number of items is whatever the page pools are holding - plus whatever's in the freelist */ - for (i = 0; i < num_orders; i++) { - struct ion_page_pool *pool = sys_heap->pools[i]; - nr_total += ion_page_pool_shrink(pool, sc->gfp_mask, 0); - } - nr_total += ion_heap_freelist_size(heap) / PAGE_SIZE; - return nr_total; - -} - -static unsigned long ion_system_heap_shrink_scan(struct shrinker *shrinker, - struct shrink_control *sc) -{ - - struct ion_heap *heap = container_of(shrinker, struct ion_heap, - shrinker); - struct ion_system_heap *sys_heap = container_of(heap, - struct ion_system_heap, - heap); - int nr_freed = 0; - int i; - - if (sc->nr_to_scan == 0) - goto end; - - /* shrink the free list first, no point in zeroing the memory if - we're just going to reclaim it */ - nr_freed += ion_heap_freelist_drain(heap, sc->nr_to_scan * PAGE_SIZE) / - PAGE_SIZE; - - if (nr_freed >= sc->nr_to_scan) - goto end; - - for (i = 0; i < num_orders; i++) { - struct ion_page_pool *pool = sys_heap->pools[i]; - - nr_freed += ion_page_pool_shrink(pool, sc->gfp_mask, - sc->nr_to_scan); - if (nr_freed >= sc->nr_to_scan) - break; - } - -end: - return nr_freed; - -} - static int ion_system_heap_debug_show(struct ion_heap *heap, struct seq_file *s, void *unused) { @@ -347,11 +306,6 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused) heap->pools[i] = pool; } - heap->heap.shrinker.scan_objects = ion_system_heap_shrink_scan; - heap->heap.shrinker.count_objects = ion_system_heap_shrink_count; - heap->heap.shrinker.seeks = DEFAULT_SEEKS; - heap->heap.shrinker.batch = 0; - register_shrinker(&heap->heap.shrinker); heap->heap.debug_show = ion_system_heap_debug_show; return &heap->heap; err_create_pool: From 53a91c68fa7b5f3ca45d2f1c88bf36a988b74e81 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Mon, 17 Feb 2014 13:58:39 -0800 Subject: [PATCH 0295/1375] staging: ion: Add private buffer flag to skip page pooling on free Currently, when we free a buffer it might actually just go back into a heap-specific page pool rather than going back to the system. This poses a problem because sometimes (like when we're running a shrinker in low memory conditions) we need to force the memory associated with the buffer to truly be relinquished to the system rather than just going back into a page pool. There isn't a use case for this flag by Ion clients, so make it a private flag. The main use case right now is to provide a mechanism for the deferred free code to force stale buffers to bypass page pooling. Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Mitchel Humpherys [jstultz: Minor commit subject tweak] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_heap.c | 19 +++++++-- drivers/staging/android/ion/ion_priv.h | 42 ++++++++++++++++++- drivers/staging/android/ion/ion_system_heap.c | 4 +- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index 49ace13ac545..bdc6a28ba8c9 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c @@ -178,7 +178,8 @@ size_t ion_heap_freelist_size(struct ion_heap *heap) return size; } -size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size) +static size_t _ion_heap_freelist_drain(struct ion_heap *heap, size_t size, + bool skip_pools) { struct ion_buffer *buffer; size_t total_drained = 0; @@ -197,6 +198,8 @@ size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size) list); list_del(&buffer->list); heap->free_list_size -= buffer->size; + if (skip_pools) + buffer->private_flags |= ION_PRIV_FLAG_SHRINKER_FREE; total_drained += buffer->size; spin_unlock(&heap->free_lock); ion_buffer_destroy(buffer); @@ -207,6 +210,16 @@ size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size) return total_drained; } +size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size) +{ + return _ion_heap_freelist_drain(heap, size, false); +} + +size_t ion_heap_freelist_shrink(struct ion_heap *heap, size_t size) +{ + return _ion_heap_freelist_drain(heap, size, true); +} + static int ion_heap_deferred_free(void *data) { struct ion_heap *heap = data; @@ -278,10 +291,10 @@ static unsigned long ion_heap_shrink_scan(struct shrinker *shrinker, /* * shrink the free list first, no point in zeroing the memory if we're - * just going to reclaim it + * just going to reclaim it. Also, skip any possible page pooling. */ if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) - freed = ion_heap_freelist_drain(heap, to_scan * PAGE_SIZE) / + freed = ion_heap_freelist_shrink(heap, to_scan * PAGE_SIZE) / PAGE_SIZE; to_scan -= freed; diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index bcf9d19b57a3..1eba3f2076a9 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -38,6 +38,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle); * @dev: back pointer to the ion_device * @heap: back pointer to the heap the buffer came from * @flags: buffer specific flags + * @private_flags: internal buffer specific flags * @size: size of the buffer * @priv_virt: private data to the buffer representable as * a void * @@ -66,6 +67,7 @@ struct ion_buffer { struct ion_device *dev; struct ion_heap *heap; unsigned long flags; + unsigned long private_flags; size_t size; union { void *priv_virt; @@ -98,7 +100,11 @@ void ion_buffer_destroy(struct ion_buffer *buffer); * @map_user map memory to userspace * * allocate, phys, and map_user return 0 on success, -errno on error. - * map_dma and map_kernel return pointer on success, ERR_PTR on error. + * map_dma and map_kernel return pointer on success, ERR_PTR on + * error. @free will be called with ION_PRIV_FLAG_SHRINKER_FREE set in + * the buffer's private_flags when called from a shrinker. In that + * case, the pages being free'd must be truly free'd back to the + * system, not put in a page pool or otherwise cached. */ struct ion_heap_ops { int (*allocate)(struct ion_heap *heap, @@ -122,6 +128,17 @@ struct ion_heap_ops { */ #define ION_HEAP_FLAG_DEFER_FREE (1 << 0) +/** + * private flags - flags internal to ion + */ +/* + * Buffer is being freed from a shrinker function. Skip any possible + * heap-specific caching mechanism (e.g. page pools). Guarantees that + * any buffer storage that came from the system allocator will be + * returned to the system allocator. + */ +#define ION_PRIV_FLAG_SHRINKER_FREE (1 << 0) + /** * struct ion_heap - represents a heap in the system * @node: rb node to put the heap on the device's tree of heaps @@ -257,6 +274,29 @@ void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer); */ size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size); +/** + * ion_heap_freelist_shrink - drain the deferred free + * list, skipping any heap-specific + * pooling or caching mechanisms + * + * @heap: the heap + * @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 + * on the size of the items in the list, or lower if there is insufficient + * total memory on the freelist. + * + * Unlike with @ion_heap_freelist_drain, don't put any pages back into + * page pools or otherwise cache the pages. Everything must be + * genuinely free'd back to the system. If you're free'ing from a + * shrinker you probably want to use this. Note that this relies on + * the heap.ops.free callback honoring the ION_PRIV_FLAG_SHRINKER_FREE + * flag. + */ +size_t ion_heap_freelist_shrink(struct ion_heap *heap, + size_t size); + /** * ion_heap_freelist_size - returns the size of the freelist in bytes * @heap: the heap diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index f453d977c80c..c92363356ae1 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -90,7 +90,7 @@ static void free_buffer_page(struct ion_system_heap *heap, { bool cached = ion_buffer_cached(buffer); - if (!cached) { + if (!cached && !(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) { struct ion_page_pool *pool = heap->pools[order_to_index(order)]; ion_page_pool_free(pool, page); } else { @@ -209,7 +209,7 @@ static void ion_system_heap_free(struct ion_buffer *buffer) /* uncached pages come from the page pools, zero them before returning for security purposes (other allocations are zerod at alloc time */ - if (!cached) + if (!cached && !(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) ion_heap_buffer_zero(buffer); for_each_sg(table->sgl, sg, table->nents, i) From 2a3fcc51639cb4ad1a841bc169a1ddb993455076 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 18 Feb 2014 09:46:33 -0300 Subject: [PATCH 0296/1375] staging: ion: ion_cma_heap: Remove '0x' when using %pa format %pa format already prints in hexadecimal format, so remove the '0x' annotation to avoid a double '0x0x' pattern. Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_cma_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index f0f98897e4b9..ce68ecfed31f 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -135,7 +135,7 @@ static int ion_cma_phys(struct ion_heap *heap, struct ion_buffer *buffer, struct device *dev = cma_heap->dev; struct ion_cma_buffer_info *info = buffer->priv_virt; - dev_dbg(dev, "Return buffer %p physical address 0x%pa\n", buffer, + dev_dbg(dev, "Return buffer %p physical address %pa\n", buffer, &info->handle); *addr = info->handle; From 20758c5b912b47939300e7f67d6d124899caedd5 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sun, 16 Feb 2014 02:40:06 -0600 Subject: [PATCH 0297/1375] Staging: comedi: addi-data: fix brace-related coding style issues in hwdrv_apci035.c This patch for hwdrv_apci035 removes some unneeded braces, and moves some improperly placed braces to the correct position, as found by checkpatch. It also removes a commented out if-statement that I found whilst cleaning braces that is identical to another un-commented if-statement directly above it, so it is just added clutter and so we can delete it to clean up further. Signed-off-by: Chase Southwood Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci035.c | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 1128c22e7517..584a1d524110 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -177,11 +177,11 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, devpriv->tsk_Current = current; devpriv->b_TimerSelectMode = data[0]; i_WatchdogNbr = data[1]; - if (data[0] == 0) { + if (data[0] == 0) ui_Mode = 2; - } else { + else ui_Mode = 0; - } + /* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); */ ui_Command = 0; /* ui_Command = ui_Command & 0xFFFFF9FEUL; */ @@ -366,8 +366,7 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); } - if (data[0] == 0) /* Stop The Watchdog */ - { + if (data[0] == 0) { /* Stop The Watchdog */ ui_Command = 0; /* @@ -377,15 +376,15 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); } /* if (data[1]==0) */ - if (data[0] == 3) /* stop all Watchdogs */ - { + if (data[0] == 3) { + /* stop all Watchdogs */ ui_Command = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { - if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { + if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) ui_Command = 0x2UL; - } else { + else ui_Command = 0x10UL; - } + i_WatchdogNbr = i_Count; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + @@ -393,30 +392,29 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, } } - if (data[0] == 4) /* start all Watchdogs */ - { + if (data[0] == 4) { + /* start all Watchdogs */ ui_Command = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { - if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { + if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) ui_Command = 0x1UL; - } else { + else ui_Command = 0x8UL; - } + i_WatchdogNbr = i_Count; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); } } - if (data[0] == 5) /* trigger all Watchdogs */ - { + if (data[0] == 5) { + /* trigger all Watchdogs */ ui_Command = 0; for (i_Count = 1; i_Count <= 4; i_Count++) { - if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { + if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) ui_Command = 0x4UL; - } else { + else ui_Command = 0x20UL; - } i_WatchdogNbr = i_Count; outl(ui_Command, @@ -488,11 +486,9 @@ static int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, /* Get the overflow status */ /***************************/ data[3] = ((ui_Status >> 0) & 1); - if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { + if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); - } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ - return insn->n; } @@ -655,8 +651,8 @@ static void v_APCI035_Interrupt(int irq, void *d) ui_StatusRegister2 = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20); - if ((((ui_StatusRegister1) & 0x8) == 0x8)) /* Test if warning relay interrupt */ - { + /* Test if warning relay interrupt */ + if ((((ui_StatusRegister1) & 0x8) == 0x8)) { /**********************************/ /* Disable the temperature warning */ /**********************************/ @@ -675,9 +671,8 @@ static void v_APCI035_Interrupt(int irq, void *d) } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */ else { - if ((ui_StatusRegister2 & 0x1) == 0x1) { + if ((ui_StatusRegister2 & 0x1) == 0x1) send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } } /* else if (((ui_StatusRegister1 & 0x8) == 0x8)) */ return; From bc0be59eb6c1eb3e675a3c750478bb4cb900ea3a Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sun, 16 Feb 2014 02:41:09 -0600 Subject: [PATCH 0298/1375] Staging: comedi: addi-data: cleanup comments in hwdrv_apci035.c This patch for hwdrv_apci035.c aligns comment blocks and makes indentation of comments consistent. Removed all "spaces before tabs" in comment indentation as well. Signed-off-by: Chase Southwood Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci035.c | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 584a1d524110..90d58017f43a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -188,17 +188,17 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); -/************************/ -/* Set the reload value */ -/************************/ + /************************/ + /* Set the reload value */ + /************************/ outl(data[3], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 4); -/*********************/ -/* Set the time unit */ -/*********************/ + /*********************/ + /* Set the time unit */ + /*********************/ outl(data[2], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 8); if (data[0] == ADDIDATA_TIMER) { - /******************************/ + /******************************/ /* Set the mode : */ /* - Disable the hardware */ /* - Disable the counter mode */ @@ -206,7 +206,7 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, /* - Disable the reset */ /* - Enable the timer mode */ /* - Set the timer mode */ - /******************************/ + /******************************/ ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL; @@ -215,14 +215,14 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, else { if (data[0] == ADDIDATA_WATCHDOG) { - /******************************/ + /******************************/ /* Set the mode : */ /* - Disable the hardware */ /* - Disable the counter mode */ /* - Disable the warning */ /* - Disable the reset */ /* - Disable the timer mode */ - /******************************/ + /******************************/ ui_Command = ui_Command & 0xFFF819E2UL; @@ -234,73 +234,73 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); -/********************************/ -/* Disable the hardware trigger */ -/********************************/ + /********************************/ + /* Disable the hardware trigger */ + /********************************/ ui_Command = ui_Command & 0xFFFFF89FUL; if (data[4] == ADDIDATA_ENABLE) { - /**********************************/ + /**********************************/ /* Set the hardware trigger level */ - /**********************************/ + /**********************************/ ui_Command = ui_Command | (data[5] << 5); } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); -/*****************************/ -/* Disable the hardware gate */ -/*****************************/ + /*****************************/ + /* Disable the hardware gate */ + /*****************************/ ui_Command = ui_Command & 0xFFFFF87FUL; if (data[6] == ADDIDATA_ENABLE) { -/*******************************/ -/* Set the hardware gate level */ -/*******************************/ + /*******************************/ + /* Set the hardware gate level */ + /*******************************/ ui_Command = ui_Command | (data[7] << 7); } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); -/*******************************/ -/* Disable the hardware output */ -/*******************************/ + /*******************************/ + /* Disable the hardware output */ + /*******************************/ ui_Command = ui_Command & 0xFFFFF9FBUL; -/*********************************/ -/* Set the hardware output level */ -/*********************************/ + /*********************************/ + /* Set the hardware output level */ + /*********************************/ ui_Command = ui_Command | (data[8] << 2); outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); if (data[9] == ADDIDATA_ENABLE) { - /************************/ + /************************/ /* Set the reload value */ - /************************/ + /************************/ outl(data[11], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 24); - /**********************/ + /**********************/ /* Set the time unite */ - /**********************/ + /**********************/ outl(data[10], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28); } ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*******************************/ + /*******************************/ /* Disable the hardware output */ - /*******************************/ + /*******************************/ ui_Command = ui_Command & 0xFFFFF9F7UL; - /*********************************/ + /*********************************/ /* Set the hardware output level */ - /*********************************/ + /*********************************/ ui_Command = ui_Command | (data[12] << 3); outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*************************************/ - /** Enable the watchdog interrupt **/ - /*************************************/ + /*************************************/ + /** Enable the watchdog interrupt **/ + /*************************************/ ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); -/*******************************/ -/* Set the interrupt selection */ -/*******************************/ + /*******************************/ + /* Set the interrupt selection */ + /*******************************/ ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16); ui_Command = (ui_Command & 0xFFFFF9FDUL) | (data[13] << 1); @@ -348,9 +348,9 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, if (data[0] == 1) { ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /**********************/ + /**********************/ /* Start the hardware */ - /**********************/ + /**********************/ ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -358,9 +358,9 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, if (data[0] == 2) { ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /***************************/ + /***************************/ /* Set the trigger command */ - /***************************/ + /***************************/ ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -369,10 +369,10 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, if (data[0] == 0) { /* Stop The Watchdog */ ui_Command = 0; -/* -* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); -* ui_Command = ui_Command & 0xFFFFF9FEUL; -*/ + /* + * ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); + * ui_Command = ui_Command & 0xFFFFF9FEUL; + */ outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); } /* if (data[1]==0) */ @@ -525,9 +525,9 @@ static int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, devpriv->tsk_Current = current; outl(0x200 | 0, devpriv->iobase + 128 + 0x4); outl(0, devpriv->iobase + 128 + 0); -/********************************/ -/* Initialise the warning value */ -/********************************/ + /********************************/ + /* Initialise the warning value */ + /********************************/ outl(0x300 | 0, devpriv->iobase + 128 + 0x4); outl((data[0] << 8), devpriv->iobase + 128 + 0); outl(0x200000UL, devpriv->iobase + 128 + 12); @@ -564,18 +564,18 @@ static int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct addi_private *devpriv = dev->private; unsigned int ui_CommandRegister = 0; -/******************/ -/* Set the start */ -/******************/ + /******************/ + /* Set the start */ + /******************/ ui_CommandRegister = 0x80000; - /******************************/ + /******************************/ /* Write the command register */ - /******************************/ + /******************************/ outl(ui_CommandRegister, devpriv->iobase + 128 + 8); -/***************************************/ -/* Read the digital value of the input */ -/***************************************/ + /***************************************/ + /* Read the digital value of the input */ + /***************************************/ data[0] = inl(devpriv->iobase + 128 + 28); return insn->n; } @@ -640,32 +640,32 @@ static void v_APCI035_Interrupt(int irq, void *d) i_WatchdogNbr = i_Flag; i_Flag = i_Flag + 1; } - /**************************************/ + /**************************************/ /* Read the interrupt status register of temperature Warning */ - /**************************************/ + /**************************************/ ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16); - /**************************************/ + /**************************************/ /* Read the interrupt status register for Watchdog/timer */ - /**************************************/ + /**************************************/ ui_StatusRegister2 = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20); /* Test if warning relay interrupt */ if ((((ui_StatusRegister1) & 0x8) == 0x8)) { - /**********************************/ + /**********************************/ /* Disable the temperature warning */ - /**********************************/ + /**********************************/ ui_ReadCommand = inl(devpriv->iobase + 128 + 12); ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL; outl(ui_ReadCommand, devpriv->iobase + 128 + 12); - /***************************/ + /***************************/ /* Read the channel number */ - /***************************/ + /***************************/ ui_ChannelNumber = inl(devpriv->iobase + 128 + 60); - /**************************************/ + /**************************************/ /* Read the digital temperature value */ - /**************************************/ + /**************************************/ ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60); send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */ From 6fcd2b697cc783894e02a42fe773da2efac5635e Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Tue, 18 Feb 2014 00:34:39 -0600 Subject: [PATCH 0299/1375] Staging: comedi: addi-data: convert printk() to dev_err() This patch for hwdrv_apci035.c changes a printk() call to a dev_err() call since this is generally preferred. It also removes a newline from the start of the error message. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 90d58017f43a..ff64540bdf7c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -227,7 +227,7 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, ui_Command = ui_Command & 0xFFF819E2UL; } else { - printk("\n The parameter for Timer/watchdog selection is in error\n"); + dev_err(dev->class_dev, "The parameter for Timer/watchdog selection is in error\n"); return -EINVAL; } } From 55761166cff31707b83d9d3282d0f77ce805ea87 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sun, 16 Feb 2014 02:41:32 -0600 Subject: [PATCH 0300/1375] Staging: comedi: addi-data: do not initialize statics to 0 in hwdrv_apci035.c This patch for hwdrv_apci035.c removes a zero initialization from two static variables. Static variables are initialized to zero by default, so doing so explicitly is not necessary. Signed-off-by: Chase Southwood Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index ff64540bdf7c..8ce3335422cd 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -106,8 +106,8 @@ static struct comedi_lrange range_apci035_ai = { } }; -static int i_WatchdogNbr = 0; -static int i_Temp = 0; +static int i_WatchdogNbr; +static int i_Temp; static int i_Flag = 1; /* +----------------------------------------------------------------------------+ From a469fe1ab88e19cad0995504973c5400cf24bb17 Mon Sep 17 00:00:00 2001 From: Gary Rookard Date: Sun, 16 Feb 2014 11:16:41 -0500 Subject: [PATCH 0301/1375] Staging: bcm: DDRInit: fix up indentation issues. fixed up a couple of indentation issues. Signed-off-by: Gary Alan Rookard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/DDRInit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index b4d5e64cf47d..f1d7cb82fd7e 100644 --- a/drivers/staging/bcm/DDRInit.c +++ b/drivers/staging/bcm/DDRInit.c @@ -1094,8 +1094,8 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; break; - default: - return -EINVAL; + default: + return -EINVAL; } break; From 75bc5fad154590e8dda5772669cf9b6f44bb873b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 18 Feb 2014 15:18:10 +0300 Subject: [PATCH 0302/1375] staging: gdm724x: cleanup alloc_tx_sdu_struct() The kfree(t_sdu->buf) sets off a private static checker warning because "t_sdu->buf" is always NULL. This function just allocates two pointers so we can re-write it to be simpler. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_usb.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 33458a583142..03b43056fcf2 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -119,28 +119,15 @@ out: static struct usb_tx_sdu *alloc_tx_sdu_struct(void) { - struct usb_tx_sdu *t_sdu = NULL; - int ret = 0; - + struct usb_tx_sdu *t_sdu; t_sdu = kzalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC); - if (!t_sdu) { - ret = -ENOMEM; - goto out; - } + if (!t_sdu) + return NULL; t_sdu->buf = kmalloc(SDU_BUF_SIZE, GFP_ATOMIC); if (!t_sdu->buf) { - ret = -ENOMEM; - goto out; - } -out: - - if (ret < 0) { - if (t_sdu) { - kfree(t_sdu->buf); - kfree(t_sdu); - } + kfree(t_sdu); return NULL; } From 4e5e9d7c66f045558d5f70f640de0093fcd875e8 Mon Sep 17 00:00:00 2001 From: "Zhao, Gang" Date: Tue, 18 Feb 2014 23:03:27 +0800 Subject: [PATCH 0303/1375] staging: wlan-ng: replace function ieee80211_dsss_chan_to_freq() Replace ieee80211_dsss_chan_to_freq() with more generic ieee80211_channel_to_frequency(), and add a variable to deal with 80 characters problem. File cfg80211.c is included by p80211netdev.c, p80211netdev.c includes , both ieee80211_channel_to_frequency() and IEEE80211_BAND_2GHZ is defined / declared in . So this change is safe. This change is a preparation for the removal of function ieee80211_{dsss_chan_to_freq, freq_to_dsss_chan}. Signed-off-by: Zhao, Gang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/cfg80211.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index a7d24c95191d..6c317304b658 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -400,6 +400,8 @@ static int prism2_scan(struct wiphy *wiphy, numbss = msg1.numbss.data; for (i = 0; i < numbss; i++) { + int freq; + memset(&msg2, 0, sizeof(msg2)); msg2.msgcode = DIDmsg_dot11req_scan_results; msg2.bssindex.data = i; @@ -414,9 +416,10 @@ static int prism2_scan(struct wiphy *wiphy, ie_buf[1] = msg2.ssid.data.len; ie_len = ie_buf[1] + 2; memcpy(&ie_buf[2], &(msg2.ssid.data.data), msg2.ssid.data.len); + freq = ieee80211_channel_to_frequency(msg2.dschannel.data, + IEEE80211_BAND_2GHZ); bss = cfg80211_inform_bss(wiphy, - ieee80211_get_channel(wiphy, - ieee80211_dsss_chan_to_freq(msg2.dschannel.data)), + ieee80211_get_channel(wiphy, freq), (const u8 *) &(msg2.bssid.data.data), msg2.timestamp.data, msg2.capinfo.data, msg2.beaconperiod.data, From cfff3e5c8d2139c38d40d90e3d9fc13721222076 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 17 Feb 2014 22:56:06 +0300 Subject: [PATCH 0304/1375] staging/bcm: two information leaks in ioctl There are a couple paths where we don't check how much data we copy back to the user. Cc: Dave Jones Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index fdebc3bba0b5..6f1997dc44c8 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -590,6 +590,8 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, struct bcm_mini_ if (IoBuffer.InputLength > sizeof(gpio_multi_info)) return -EINVAL; + if (IoBuffer.OutputLength > sizeof(gpio_multi_info)) + IoBuffer.OutputLength = sizeof(gpio_multi_info); if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) return -EFAULT; @@ -680,6 +682,8 @@ static int bcm_char_ioctl_gpio_mode_request(void __user *argp, struct bcm_mini_a if (IoBuffer.InputLength > sizeof(gpio_multi_mode)) return -EINVAL; + if (IoBuffer.OutputLength > sizeof(gpio_multi_mode)) + IoBuffer.OutputLength = sizeof(gpio_multi_mode); if (copy_from_user(&gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength)) return -EFAULT; From ee2104ea865f8a12eebb382aa502f248e14a5a2d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 17 Feb 2014 22:57:31 +0300 Subject: [PATCH 0305/1375] staging/bcm: integer underflow leads to Oom We do: if (NOB > DEFAULT_BUFF_SIZE) BuffSize = DEFAULT_BUFF_SIZE; else BuffSize = NOB; Since NOB can be negative it results in a larger than intended BuffSize and makes kzalloc() fail. The code is still a bit crap because it lets the users read as much as they want from nvram, but I don't know what a sensible upper limit should be. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 6f1997dc44c8..5e4dfe031040 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1894,7 +1894,7 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, struct bcm_mini_adapte { struct bcm_nvm_readwrite stNVMRead; struct bcm_ioctl_buffer IoBuffer; - INT NOB; + unsigned int NOB; INT BuffSize; INT ReadOffset = 0; UINT ReadBytes = 0; From f28edc818418207923e2bb3e830a0e3bd748c716 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:35 -0700 Subject: [PATCH 0306/1375] staging: comedi: pcl812: convert boardinfo declaration to C99 format To reduce editing errors and make the data more maintainable, convert the boardinfo declaration to C99 format. For aesthetics, move the declaration closer to the definition and remove the unnecessary comments in the definition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 398 +++++++++++++++++++----- 1 file changed, 325 insertions(+), 73 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 095b3253054a..609036005169 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -331,23 +331,332 @@ static const struct comedi_lrange range_a821pgh_ai = { }; struct pcl812_board { - - const char *name; /* board name */ - int board_type; /* type of this board */ - int n_aichan; /* num of AI chans in S.E. */ - int n_aichan_diff; /* DIFF num of chans */ - int n_aochan; /* num of DA chans */ - int n_dichan; /* DI and DO chans */ + const char *name; + int board_type; + int n_aichan; + int n_aichan_diff; + int n_aochan; + int n_dichan; int n_dochan; - int ai_maxdata; /* AI resolution */ - unsigned int ai_ns_min; /* max sample speed of card v ns */ - unsigned int i8254_osc_base; /* clock base */ - const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ - const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ - unsigned int IRQbits; /* allowed IRQ */ - unsigned char DMAbits; /* allowed DMA chans */ - unsigned char io_range; /* iorange for this board */ - unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */ + int ai_maxdata; + unsigned int ai_ns_min; + unsigned int i8254_osc_base; + const struct comedi_lrange *rangelist_ai; + const struct comedi_lrange *rangelist_ao; + unsigned int IRQbits; + unsigned char DMAbits; + unsigned char io_range; + unsigned char haveMPC508; +}; + +static const struct pcl812_board boardtypes[] = { + { + .name = "pcl812", + .board_type = boardPCL812, + .n_aichan = 16, + .n_aichan_diff = 0, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 33000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_bipolar10, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "pcl812pg", + .board_type = boardPCL812PG, + .n_aichan = 16, + .n_aichan_diff = 0, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 33000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_pcl812pg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "acl8112pg", + .board_type = boardPCL812PG, + .n_aichan = 16, + .n_aichan_diff = 0, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_pcl812pg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "acl8112dg", + .board_type = boardACL8112, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_acl8112dg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 1, + }, { + .name = "acl8112hg", + .board_type = boardACL8112, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_acl8112hg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 1, + }, { + .name = "a821pgl", + .board_type = boardA821, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_pcl813b_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0x000c, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "a821pglnda", + .board_type = boardA821, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 0, + .n_dichan = 0, + .n_dochan = 0, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_pcl813b_ai, + .rangelist_ao = NULL, + .IRQbits = 0x000c, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "a821pgh", + .board_type = boardA821, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_a821pgh_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0x000c, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "a822pgl", + .board_type = boardACL8112, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_acl8112dg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "a822pgh", + .board_type = boardACL8112, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_acl8112hg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "a823pgl", + .board_type = boardACL8112, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 8000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_acl8112dg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "a823pgh", + .board_type = boardACL8112, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0x0fff, + .ai_ns_min = 8000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_acl8112hg_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "pcl813", + .board_type = boardPCL813, + .n_aichan = 32, + .n_aichan_diff = 0, + .n_aochan = 0, + .n_dichan = 0, + .n_dochan = 0, + .ai_maxdata = 0x0fff, + .ai_ns_min = 0, + .i8254_osc_base = 0, + .rangelist_ai = &range_pcl813b_ai, + .rangelist_ao = NULL, + .IRQbits = 0x0000, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "pcl813b", + .board_type = boardPCL813B, + .n_aichan = 32, + .n_aichan_diff = 0, + .n_aochan = 0, + .n_dichan = 0, + .n_dochan = 0, + .ai_maxdata = 0x0fff, + .ai_ns_min = 0, + .i8254_osc_base = 0, + .rangelist_ai = &range_pcl813b_ai, + .rangelist_ao = NULL, + .IRQbits = 0x0000, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "acl8113", + .board_type = boardACL8113, + .n_aichan = 32, + .n_aichan_diff = 0, + .n_aochan = 0, + .n_dichan = 0, + .n_dochan = 0, + .ai_maxdata = 0x0fff, + .ai_ns_min = 0, + .i8254_osc_base = 0, + .rangelist_ai = &range_acl8113_1_ai, + .rangelist_ao = NULL, + .IRQbits = 0x0000, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "iso813", + .board_type = boardISO813, + .n_aichan = 32, + .n_aichan_diff = 0, + .n_aochan = 0, + .n_dichan = 0, + .n_dochan = 0, + .ai_maxdata = 0x0fff, + .ai_ns_min = 0, + .i8254_osc_base = 0, + .rangelist_ai = &range_iso813_1_ai, + .rangelist_ao = NULL, + .IRQbits = 0x0000, + .DMAbits = 0x00, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, { + .name = "acl8216", + .board_type = boardACL8216, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0xffff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_pcl813b2_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 1, + }, { + .name = "a826pg", + .board_type = boardACL8216, + .n_aichan = 16, + .n_aichan_diff = 8, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_maxdata = 0xffff, + .ai_ns_min = 10000, + .i8254_osc_base = I8254_OSC_BASE_2MHZ, + .rangelist_ai = &range_pcl813b2_ai, + .rangelist_ao = &range_unipolar5, + .IRQbits = 0xdcfc, + .DMAbits = 0x0a, + .io_range = PCLx1x_IORANGE, + .haveMPC508 = 0, + }, }; struct pcl812_private { @@ -1400,63 +1709,6 @@ static void pcl812_detach(struct comedi_device *dev) comedi_legacy_detach(dev); } -static const struct pcl812_board boardtypes[] = { - {"pcl812", boardPCL812, 16, 0, 2, 16, 16, 0x0fff, - 33000, I8254_OSC_BASE_2MHZ, &range_bipolar10, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"pcl812pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff, - 33000, I8254_OSC_BASE_2MHZ, &range_pcl812pg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"acl8112pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_pcl812pg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"acl8112dg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_acl8112dg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 1}, - {"acl8112hg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_acl8112hg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 1}, - {"a821pgl", boardA821, 16, 8, 1, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_pcl813b_ai, &range_unipolar5, - 0x000c, 0x00, PCLx1x_IORANGE, 0}, - {"a821pglnda", boardA821, 16, 8, 0, 0, 0, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_pcl813b_ai, NULL, - 0x000c, 0x00, PCLx1x_IORANGE, 0}, - {"a821pgh", boardA821, 16, 8, 1, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_a821pgh_ai, &range_unipolar5, - 0x000c, 0x00, PCLx1x_IORANGE, 0}, - {"a822pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_acl8112dg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"a822pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff, - 10000, I8254_OSC_BASE_2MHZ, &range_acl8112hg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"a823pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff, - 8000, I8254_OSC_BASE_2MHZ, &range_acl8112dg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"a823pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff, - 8000, I8254_OSC_BASE_2MHZ, &range_acl8112hg_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, - {"pcl813", boardPCL813, 32, 0, 0, 0, 0, 0x0fff, - 0, 0, &range_pcl813b_ai, NULL, - 0x0000, 0x00, PCLx1x_IORANGE, 0}, - {"pcl813b", boardPCL813B, 32, 0, 0, 0, 0, 0x0fff, - 0, 0, &range_pcl813b_ai, NULL, - 0x0000, 0x00, PCLx1x_IORANGE, 0}, - {"acl8113", boardACL8113, 32, 0, 0, 0, 0, 0x0fff, - 0, 0, &range_acl8113_1_ai, NULL, - 0x0000, 0x00, PCLx1x_IORANGE, 0}, - {"iso813", boardISO813, 32, 0, 0, 0, 0, 0x0fff, - 0, 0, &range_iso813_1_ai, NULL, - 0x0000, 0x00, PCLx1x_IORANGE, 0}, - {"acl8216", boardACL8216, 16, 8, 2, 16, 16, 0xffff, - 10000, I8254_OSC_BASE_2MHZ, &range_pcl813b2_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 1}, - {"a826pg", boardACL8216, 16, 8, 2, 16, 16, 0xffff, - 10000, I8254_OSC_BASE_2MHZ, &range_pcl813b2_ai, &range_unipolar5, - 0xdcfc, 0x0a, PCLx1x_IORANGE, 0}, -}; - static struct comedi_driver pcl812_driver = { .driver_name = "pcl812", .module = THIS_MODULE, From a094dbdd00f2c82f7baf0b534667e5b5f8c65bcb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:36 -0700 Subject: [PATCH 0307/1375] staging: comedi: pcl816: convert boardinfo declaration to C99 format To reduce editing errors and make the data more maintainable, convert the boardinfo declaration to C99 format. For aesthetics, move the declaration closer to the definition and remove the unnecessary comments in the definition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 94 +++++++++++++++---------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 044722f3a51f..3bae039ea7bd 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -95,24 +95,63 @@ static const struct comedi_lrange range_pcl816 = { }; struct pcl816_board { + const char *name; + int n_ranges; + int n_aichan; + unsigned int ai_ns_min; + int n_aochan; + int n_dichan; + int n_dochan; + const struct comedi_lrange *ai_range_type; + const struct comedi_lrange *ao_range_type; + unsigned int io_range; + unsigned int IRQbits; + unsigned int DMAbits; + int ai_maxdata; + int ao_maxdata; + int ai_chanlist; + int ao_chanlist; + int i8254_osc_base; +}; - const char *name; /* board name */ - int n_ranges; /* len of range list */ - int n_aichan; /* num of A/D chans in diferencial mode */ - unsigned int ai_ns_min; /* minimal allowed delay between samples (in ns) */ - int n_aochan; /* num of D/A chans */ - int n_dichan; /* num of DI chans */ - int n_dochan; /* num of DO chans */ - const struct comedi_lrange *ai_range_type; /* default A/D rangelist */ - const struct comedi_lrange *ao_range_type; /* default D/A rangelist */ - unsigned int io_range; /* len of IO space */ - unsigned int IRQbits; /* allowed interrupts */ - unsigned int DMAbits; /* allowed DMA chans */ - int ai_maxdata; /* maxdata for A/D */ - int ao_maxdata; /* maxdata for D/A */ - int ai_chanlist; /* allowed len of channel list A/D */ - int ao_chanlist; /* allowed len of channel list D/A */ - int i8254_osc_base; /* 1/frequency of on board oscilator in ns */ +static const struct pcl816_board boardtypes[] = { + { + .name = "pcl816", + .n_ranges = 8, + .n_aichan = 16, + .ai_ns_min = 10000, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl816, + .ao_range_type = &range_pcl816, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xffff, + .ao_maxdata = 0xffff, + .ai_chanlist = 1024, + .ao_chanlist = 1, + .i8254_osc_base = I8254_OSC_BASE_10MHZ, + }, { + .name = "pcl814b", + .n_ranges = 8, + .n_aichan = 16, + .ai_ns_min = 10000, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl816, + .ao_range_type = &range_pcl816, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0x3fff, + .ao_maxdata = 0x3fff, + .ai_chanlist = 1024, + .ao_chanlist = 1, + .i8254_osc_base = I8254_OSC_BASE_10MHZ, + }, }; struct pcl816_private { @@ -1002,27 +1041,6 @@ static void pcl816_detach(struct comedi_device *dev) comedi_legacy_detach(dev); } -static const struct pcl816_board boardtypes[] = { - {"pcl816", 8, 16, 10000, 1, 16, 16, &range_pcl816, - &range_pcl816, PCLx1x_RANGE, - 0x00fc, /* IRQ mask */ - 0x0a, /* DMA mask */ - 0xffff, /* 16-bit card */ - 0xffff, /* D/A maxdata */ - 1024, - 1, /* ao chan list */ - I8254_OSC_BASE_10MHZ}, - {"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816, - &range_pcl816, PCLx1x_RANGE, - 0x00fc, - 0x0a, - 0x3fff, /* 14 bit card */ - 0x3fff, - 1024, - 1, - I8254_OSC_BASE_10MHZ}, -}; - static struct comedi_driver pcl816_driver = { .driver_name = "pcl816", .module = THIS_MODULE, From 43f1b6e9fa755ea6937f121b769716358751fd69 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:37 -0700 Subject: [PATCH 0308/1375] staging: comedi: pcl818: convert boardinfo declaration to C99 format To reduce editing errors and make the data more maintainable, convert the boardinfo declaration to C99 format. For aesthetics, move the declaration closer to the definition and remove the unnecessary comments in the definition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 188 ++++++++++++++++++------ 1 file changed, 146 insertions(+), 42 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 9087e54537ec..dcbee0a23821 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -262,26 +262,155 @@ static const struct comedi_lrange range718_unipolar1 = { }; struct pcl818_board { - - const char *name; /* driver name */ - int n_ranges; /* len of range list */ - int n_aichan_se; /* num of A/D chans in single ended mode */ - int n_aichan_diff; /* num of A/D chans in diferencial mode */ - unsigned int ns_min; /* minimal allowed delay between samples (in ns) */ - int n_aochan; /* num of D/A chans */ - int n_dichan; /* num of DI chans */ - int n_dochan; /* num of DO chans */ - const struct comedi_lrange *ai_range_type; /* default A/D rangelist */ - const struct comedi_lrange *ao_range_type; /* default D/A rangelist */ - unsigned int io_range; /* len of IO space */ - unsigned int IRQbits; /* allowed interrupts */ - unsigned int DMAbits; /* allowed DMA chans */ - int ai_maxdata; /* maxdata for A/D */ - int ao_maxdata; /* maxdata for D/A */ - unsigned char fifo; /* 1=board has FIFO */ + const char *name; + int n_ranges; + int n_aichan_se; + int n_aichan_diff; + unsigned int ns_min; + int n_aochan; + int n_dichan; + int n_dochan; + const struct comedi_lrange *ai_range_type; + const struct comedi_lrange *ao_range_type; + unsigned int io_range; + unsigned int IRQbits; + unsigned int DMAbits; + int ai_maxdata; + int ao_maxdata; + unsigned char fifo; int is_818; }; +static const struct pcl818_board boardtypes[] = { + { + .name = "pcl818l", + .n_ranges = 4, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 25000, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl818l_l_ai, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 0, + .is_818 = 1, + }, { + .name = "pcl818h", + .n_ranges = 9, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 10000, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl818h_ai, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 0, + .is_818 = 1, + }, { + .name = "pcl818hd", + .n_ranges = 9, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 10000, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl818h_ai, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 1, + .is_818 = 1, + }, { + .name = "pcl818hg", + .n_ranges = 12, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 10000, + .n_aochan = 1, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl818hg_ai, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 1, + .is_818 = 1, + }, { + .name = "pcl818", + .n_ranges = 9, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 10000, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl818h_ai, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 0, + .is_818 = 1, + }, { + .name = "pcl718", + .n_ranges = 1, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 16000, + .n_aochan = 2, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_unipolar5, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 0, + .is_818 = 0, + }, { + .name = "pcm3718", + .n_ranges = 9, + .n_aichan_se = 16, + .n_aichan_diff = 8, + .ns_min = 10000, + .n_aochan = 0, + .n_dichan = 16, + .n_dochan = 16, + .ai_range_type = &range_pcl818h_ai, + .ao_range_type = &range_unipolar5, + .io_range = PCLx1x_RANGE, + .IRQbits = 0x00fc, + .DMAbits = 0x0a, + .ai_maxdata = 0xfff, + .ao_maxdata = 0xfff, + .fifo = 0, + .is_818 = 1, + }, +}; + struct pcl818_private { unsigned int dma; /* used DMA, 0=don't use DMA */ @@ -1435,31 +1564,6 @@ static void pcl818_detach(struct comedi_device *dev) comedi_legacy_detach(dev); } -static const struct pcl818_board boardtypes[] = { - {"pcl818l", 4, 16, 8, 25000, 1, 16, 16, &range_pcl818l_l_ai, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 0, 1}, - {"pcl818h", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 0, 1}, - {"pcl818hd", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 1, 1}, - {"pcl818hg", 12, 16, 8, 10000, 1, 16, 16, &range_pcl818hg_ai, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 1, 1}, - {"pcl818", 9, 16, 8, 10000, 2, 16, 16, &range_pcl818h_ai, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 0, 1}, - {"pcl718", 1, 16, 8, 16000, 2, 16, 16, &range_unipolar5, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 0, 0}, - /* pcm3718 */ - {"pcm3718", 9, 16, 8, 10000, 0, 16, 16, &range_pcl818h_ai, - &range_unipolar5, PCLx1x_RANGE, 0x00fc, - 0x0a, 0xfff, 0xfff, 0, 1 /* XXX ? */ }, -}; - static struct comedi_driver pcl818_driver = { .driver_name = "pcl818", .module = THIS_MODULE, From d9e19eb5f041f3f34e7c7e4b86461ec0ca328659 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:38 -0700 Subject: [PATCH 0309/1375] staging: comedi: pcl812: remove 0/NULL initialzation in boardinfo The unlisted members in the boardinfo declaration will default to 0/NULL. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 61 ------------------------- 1 file changed, 61 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 609036005169..e1857cf1dba0 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -354,7 +354,6 @@ static const struct pcl812_board boardtypes[] = { .name = "pcl812", .board_type = boardPCL812, .n_aichan = 16, - .n_aichan_diff = 0, .n_aochan = 2, .n_dichan = 16, .n_dochan = 16, @@ -366,12 +365,10 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "pcl812pg", .board_type = boardPCL812PG, .n_aichan = 16, - .n_aichan_diff = 0, .n_aochan = 2, .n_dichan = 16, .n_dochan = 16, @@ -383,12 +380,10 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "acl8112pg", .board_type = boardPCL812PG, .n_aichan = 16, - .n_aichan_diff = 0, .n_aochan = 2, .n_dichan = 16, .n_dochan = 16, @@ -400,7 +395,6 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "acl8112dg", .board_type = boardACL8112, @@ -449,26 +443,18 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_pcl813b_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "a821pglnda", .board_type = boardA821, .n_aichan = 16, .n_aichan_diff = 8, - .n_aochan = 0, - .n_dichan = 0, - .n_dochan = 0, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl813b_ai, - .rangelist_ao = NULL, .IRQbits = 0x000c, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "a821pgh", .board_type = boardA821, @@ -483,9 +469,7 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_a821pgh_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "a822pgl", .board_type = boardACL8112, @@ -502,7 +486,6 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "a822pgh", .board_type = boardACL8112, @@ -519,7 +502,6 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "a823pgl", .board_type = boardACL8112, @@ -536,7 +518,6 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "a823pgh", .board_type = boardACL8112, @@ -553,75 +534,34 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "pcl813", .board_type = boardPCL813, .n_aichan = 32, - .n_aichan_diff = 0, - .n_aochan = 0, - .n_dichan = 0, - .n_dochan = 0, .ai_maxdata = 0x0fff, - .ai_ns_min = 0, - .i8254_osc_base = 0, .rangelist_ai = &range_pcl813b_ai, - .rangelist_ao = NULL, - .IRQbits = 0x0000, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "pcl813b", .board_type = boardPCL813B, .n_aichan = 32, - .n_aichan_diff = 0, - .n_aochan = 0, - .n_dichan = 0, - .n_dochan = 0, .ai_maxdata = 0x0fff, - .ai_ns_min = 0, - .i8254_osc_base = 0, .rangelist_ai = &range_pcl813b_ai, - .rangelist_ao = NULL, - .IRQbits = 0x0000, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "acl8113", .board_type = boardACL8113, .n_aichan = 32, - .n_aichan_diff = 0, - .n_aochan = 0, - .n_dichan = 0, - .n_dochan = 0, .ai_maxdata = 0x0fff, - .ai_ns_min = 0, - .i8254_osc_base = 0, .rangelist_ai = &range_acl8113_1_ai, - .rangelist_ao = NULL, - .IRQbits = 0x0000, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "iso813", .board_type = boardISO813, .n_aichan = 32, - .n_aichan_diff = 0, - .n_aochan = 0, - .n_dichan = 0, - .n_dochan = 0, .ai_maxdata = 0x0fff, - .ai_ns_min = 0, - .i8254_osc_base = 0, .rangelist_ai = &range_iso813_1_ai, - .rangelist_ao = NULL, - .IRQbits = 0x0000, - .DMAbits = 0x00, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, { .name = "acl8216", .board_type = boardACL8216, @@ -655,7 +595,6 @@ static const struct pcl812_board boardtypes[] = { .IRQbits = 0xdcfc, .DMAbits = 0x0a, .io_range = PCLx1x_IORANGE, - .haveMPC508 = 0, }, }; From 04f788694201a1062bb05d7a99937eef68c8c095 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:39 -0700 Subject: [PATCH 0310/1375] staging: comedi: pcl818: remove 0/NULL initialzation in boardinfo The unlisted members in the boardinfo declaration will default to 0/NULL. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index dcbee0a23821..3dd9d98157d3 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -298,7 +298,6 @@ static const struct pcl818_board boardtypes[] = { .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 0, .is_818 = 1, }, { .name = "pcl818h", @@ -316,7 +315,6 @@ static const struct pcl818_board boardtypes[] = { .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 0, .is_818 = 1, }, { .name = "pcl818hd", @@ -370,7 +368,6 @@ static const struct pcl818_board boardtypes[] = { .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 0, .is_818 = 1, }, { .name = "pcl718", @@ -388,15 +385,12 @@ static const struct pcl818_board boardtypes[] = { .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 0, - .is_818 = 0, }, { .name = "pcm3718", .n_ranges = 9, .n_aichan_se = 16, .n_aichan_diff = 8, .ns_min = 10000, - .n_aochan = 0, .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, @@ -406,7 +400,6 @@ static const struct pcl818_board boardtypes[] = { .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 0, .is_818 = 1, }, }; From 5fd2ca8444c1af412e8796b861c8dbf5e03aeb85 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:40 -0700 Subject: [PATCH 0311/1375] staging: comedi: pcl812: remove 'io_range' from boardinfo The 'io_range' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index e1857cf1dba0..062c011b7a46 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -131,8 +131,6 @@ #define boardACL8216 8 /* and ICP DAS A-826PG */ #define boardA821 9 /* PGH, PGL, PGL/NDA versions */ -#define PCLx1x_IORANGE 16 - #define PCL812_CTR0 0 #define PCL812_CTR1 1 #define PCL812_CTR2 2 @@ -345,7 +343,6 @@ struct pcl812_board { const struct comedi_lrange *rangelist_ao; unsigned int IRQbits; unsigned char DMAbits; - unsigned char io_range; unsigned char haveMPC508; }; @@ -364,7 +361,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "pcl812pg", .board_type = boardPCL812PG, @@ -379,7 +375,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "acl8112pg", .board_type = boardPCL812PG, @@ -394,7 +389,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "acl8112dg", .board_type = boardACL8112, @@ -410,7 +404,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, .haveMPC508 = 1, }, { .name = "acl8112hg", @@ -427,7 +420,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, .haveMPC508 = 1, }, { .name = "a821pgl", @@ -443,7 +435,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_pcl813b_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, - .io_range = PCLx1x_IORANGE, }, { .name = "a821pglnda", .board_type = boardA821, @@ -454,7 +445,6 @@ static const struct pcl812_board boardtypes[] = { .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl813b_ai, .IRQbits = 0x000c, - .io_range = PCLx1x_IORANGE, }, { .name = "a821pgh", .board_type = boardA821, @@ -469,7 +459,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_a821pgh_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, - .io_range = PCLx1x_IORANGE, }, { .name = "a822pgl", .board_type = boardACL8112, @@ -485,7 +474,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "a822pgh", .board_type = boardACL8112, @@ -501,7 +489,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "a823pgl", .board_type = boardACL8112, @@ -517,7 +504,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "a823pgh", .board_type = boardACL8112, @@ -533,35 +519,30 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, { .name = "pcl813", .board_type = boardPCL813, .n_aichan = 32, .ai_maxdata = 0x0fff, .rangelist_ai = &range_pcl813b_ai, - .io_range = PCLx1x_IORANGE, }, { .name = "pcl813b", .board_type = boardPCL813B, .n_aichan = 32, .ai_maxdata = 0x0fff, .rangelist_ai = &range_pcl813b_ai, - .io_range = PCLx1x_IORANGE, }, { .name = "acl8113", .board_type = boardACL8113, .n_aichan = 32, .ai_maxdata = 0x0fff, .rangelist_ai = &range_acl8113_1_ai, - .io_range = PCLx1x_IORANGE, }, { .name = "iso813", .board_type = boardISO813, .n_aichan = 32, .ai_maxdata = 0x0fff, .rangelist_ai = &range_iso813_1_ai, - .io_range = PCLx1x_IORANGE, }, { .name = "acl8216", .board_type = boardACL8216, @@ -577,7 +558,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, .haveMPC508 = 1, }, { .name = "a826pg", @@ -594,7 +574,6 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, - .io_range = PCLx1x_IORANGE, }, }; @@ -1345,7 +1324,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct comedi_subdevice *s; int n_subdevices; - ret = comedi_request_region(dev, it->options[0], board->io_range); + ret = comedi_request_region(dev, it->options[0], 0x10); if (ret) return ret; From 2599048aeb1a78c312f1b40cfe9d1aa9743c310d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:41 -0700 Subject: [PATCH 0312/1375] staging: comedi: pcl816: remove 'io_range' from boardinfo The 'io_range' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 3bae039ea7bd..05cfdc5f3ed3 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -44,10 +44,6 @@ Configuration Options: #include "comedi_fc.h" #include "8253.h" -/* boards constants */ -/* IO space len */ -#define PCLx1x_RANGE 16 - /* INTEL 8254 counters */ #define PCL816_CTR0 4 #define PCL816_CTR1 5 @@ -104,7 +100,6 @@ struct pcl816_board { int n_dochan; const struct comedi_lrange *ai_range_type; const struct comedi_lrange *ao_range_type; - unsigned int io_range; unsigned int IRQbits; unsigned int DMAbits; int ai_maxdata; @@ -125,7 +120,6 @@ static const struct pcl816_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl816, .ao_range_type = &range_pcl816, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xffff, @@ -143,7 +137,6 @@ static const struct pcl816_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl816, .ao_range_type = &range_pcl816, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0x3fff, @@ -884,7 +877,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* int i; */ struct comedi_subdevice *s; - ret = comedi_request_region(dev, it->options[0], board->io_range); + ret = comedi_request_region(dev, it->options[0], 0x10); if (ret) return ret; From d61255883967474fd68c2a927518c87e53b10f53 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:42 -0700 Subject: [PATCH 0313/1375] staging: comedi: pcl818: remove 'io_range' from boardinfo The 'io_range' is the same for all board types. Remove this data from the boardinfo. The i/o resource size is larger for board types that have a FIFO but this larger region is only requested if the user wants to use the fifo. Modify the pcl818_attach() to remove the need for the 'io_range' in the private data. For aesthetics, rename the 'fifo' member in the boardinfo to 'has_fifo' and change it to a bit-field. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 31 +++++++------------------ 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 3dd9d98157d3..4f195dbccba4 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -121,11 +121,6 @@ A word or two about DMA. Driver support DMA operations at two ways: #define boardPCL818 4 #define boardPCL718 5 -/* IO space len */ -#define PCLx1x_RANGE 16 -/* IO space len if we use FIFO */ -#define PCLx1xFIFO_RANGE 32 - /* W: clear INT request */ #define PCL818_CLRINT 8 /* R: return status byte */ @@ -272,12 +267,11 @@ struct pcl818_board { int n_dochan; const struct comedi_lrange *ai_range_type; const struct comedi_lrange *ao_range_type; - unsigned int io_range; unsigned int IRQbits; unsigned int DMAbits; int ai_maxdata; int ao_maxdata; - unsigned char fifo; + unsigned int has_fifo:1; int is_818; }; @@ -293,7 +287,6 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818l_l_ai, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -310,7 +303,6 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -327,12 +319,11 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 1, + .has_fifo = 1, .is_818 = 1, }, { .name = "pcl818hg", @@ -345,12 +336,11 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818hg_ai, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, - .fifo = 1, + .has_fifo = 1, .is_818 = 1, }, { .name = "pcl818", @@ -363,7 +353,6 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -380,7 +369,6 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_unipolar5, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -395,7 +383,6 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .ao_range_type = &range_unipolar5, - .io_range = PCLx1x_RANGE, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -407,7 +394,6 @@ static const struct pcl818_board boardtypes[] = { struct pcl818_private { unsigned int dma; /* used DMA, 0=don't use DMA */ - unsigned int io_range; unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */ unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */ unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */ @@ -1345,13 +1331,12 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv) return -ENOMEM; - devpriv->io_range = board->io_range; - if ((board->fifo) && (it->options[2] == -1)) { - /* we've board with FIFO and we want to use FIFO */ - devpriv->io_range = PCLx1xFIFO_RANGE; + /* should we use the FIFO? */ + if (board->has_fifo && it->options[2] == -1) devpriv->usefifo = 1; - } - ret = comedi_request_region(dev, it->options[0], devpriv->io_range); + + ret = comedi_request_region(dev, it->options[0], + devpriv->usefifo ? 0x20 : 0x10); if (ret) return ret; From ac6d4856e3467ecb644fb087ce6bdb9017de987e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:43 -0700 Subject: [PATCH 0314/1375] staging: comedi: pcl812: remove 'i8254_osc_base' from boardinfo The 'i8254_osc_base' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 062c011b7a46..9215a5d5de5f 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -338,7 +338,6 @@ struct pcl812_board { int n_dochan; int ai_maxdata; unsigned int ai_ns_min; - unsigned int i8254_osc_base; const struct comedi_lrange *rangelist_ai; const struct comedi_lrange *rangelist_ao; unsigned int IRQbits; @@ -356,7 +355,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 33000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_bipolar10, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -370,7 +368,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 33000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl812pg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -384,7 +381,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl812pg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -399,7 +395,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_acl8112dg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -415,7 +410,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_acl8112hg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -431,7 +425,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl813b_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, @@ -442,7 +435,6 @@ static const struct pcl812_board boardtypes[] = { .n_aichan_diff = 8, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl813b_ai, .IRQbits = 0x000c, }, { @@ -455,7 +447,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_a821pgh_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, @@ -469,7 +460,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_acl8112dg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -484,7 +474,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_acl8112hg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -499,7 +488,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 8000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_acl8112dg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -514,7 +502,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 8000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_acl8112hg_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -553,7 +540,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0xffff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl813b2_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -569,7 +555,6 @@ static const struct pcl812_board boardtypes[] = { .n_dochan = 16, .ai_maxdata = 0xffff, .ai_ns_min = 10000, - .i8254_osc_base = I8254_OSC_BASE_2MHZ, .rangelist_ai = &range_pcl813b2_ai, .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, @@ -833,7 +818,7 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; - i8253_cascade_ns_to_timer(board->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < board->ai_ns_min) @@ -861,7 +846,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->convert_src == TRIG_TIMER) { if (cmd->convert_arg < board->ai_ns_min) cmd->convert_arg = board->ai_ns_min; - i8253_cascade_ns_to_timer(board->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags); } From 43669f4b2a81678912d07aece9b908d71ae36dc0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:44 -0700 Subject: [PATCH 0315/1375] staging: comedi: pcl816: remove 'i8254_osc_base' from boardinfo The 'i8254_osc_base' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 05cfdc5f3ed3..8a10738e013a 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -106,7 +106,6 @@ struct pcl816_board { int ao_maxdata; int ai_chanlist; int ao_chanlist; - int i8254_osc_base; }; static const struct pcl816_board boardtypes[] = { @@ -126,7 +125,6 @@ static const struct pcl816_board boardtypes[] = { .ao_maxdata = 0xffff, .ai_chanlist = 1024, .ao_chanlist = 1, - .i8254_osc_base = I8254_OSC_BASE_10MHZ, }, { .name = "pcl814b", .n_ranges = 8, @@ -143,7 +141,6 @@ static const struct pcl816_board boardtypes[] = { .ao_maxdata = 0x3fff, .ai_chanlist = 1024, .ao_chanlist = 1, - .i8254_osc_base = I8254_OSC_BASE_10MHZ, }, }; @@ -480,7 +477,7 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; - i8253_cascade_ns_to_timer(board->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < board->ai_ns_min) @@ -519,7 +516,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->convert_arg < board->ai_ns_min) cmd->convert_arg = board->ai_ns_min; - i8253_cascade_ns_to_timer(board->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags); From b157f34f6e78e2e2e9add73ebc4db40f891f3bb2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:45 -0700 Subject: [PATCH 0316/1375] staging: comedi: pcl812: remove 'rangelist_ao' from boardinfo The 'rangelist_ao' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 9215a5d5de5f..7b97dbe7276f 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -339,7 +339,6 @@ struct pcl812_board { int ai_maxdata; unsigned int ai_ns_min; const struct comedi_lrange *rangelist_ai; - const struct comedi_lrange *rangelist_ao; unsigned int IRQbits; unsigned char DMAbits; unsigned char haveMPC508; @@ -356,7 +355,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 33000, .rangelist_ai = &range_bipolar10, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -369,7 +367,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 33000, .rangelist_ai = &range_pcl812pg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -382,7 +379,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl812pg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -396,7 +392,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, .haveMPC508 = 1, @@ -411,7 +406,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, .haveMPC508 = 1, @@ -426,7 +420,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, }, { .name = "a821pglnda", @@ -448,7 +441,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_a821pgh_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0x000c, }, { .name = "a822pgl", @@ -461,7 +453,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -475,7 +466,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -489,7 +479,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 8000, .rangelist_ai = &range_acl8112dg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -503,7 +492,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0x0fff, .ai_ns_min = 8000, .rangelist_ai = &range_acl8112hg_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, { @@ -541,7 +529,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0xffff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, .haveMPC508 = 1, @@ -556,7 +543,6 @@ static const struct pcl812_board boardtypes[] = { .ai_maxdata = 0xffff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, - .rangelist_ao = &range_unipolar5, .IRQbits = 0xdcfc, .DMAbits = 0x0a, }, @@ -1521,7 +1507,7 @@ no_dma: s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = board->n_aochan; s->maxdata = 0xfff; - s->range_table = board->rangelist_ao; + s->range_table = &range_unipolar5; s->insn_read = pcl812_ao_insn_read; s->insn_write = pcl812_ao_insn_write; switch (board->board_type) { From 71b7b12ec96618ebb94b3a89ad0f1d04af53549f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:46 -0700 Subject: [PATCH 0317/1375] staging: comedi: pcl816: remove 'rangelist_ao' from boardinfo The 'rangelist_ao' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 8a10738e013a..5af687ab6b22 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -99,7 +99,6 @@ struct pcl816_board { int n_dichan; int n_dochan; const struct comedi_lrange *ai_range_type; - const struct comedi_lrange *ao_range_type; unsigned int IRQbits; unsigned int DMAbits; int ai_maxdata; @@ -118,7 +117,6 @@ static const struct pcl816_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl816, - .ao_range_type = &range_pcl816, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xffff, @@ -134,7 +132,6 @@ static const struct pcl816_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl816, - .ao_range_type = &range_pcl816, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0x3fff, @@ -989,7 +986,7 @@ case COMEDI_SUBD_AO: s->n_chan = board->n_aochan; s->maxdata = board->ao_maxdata; s->len_chanlist = board->ao_chanlist; - s->range_table = board->ao_range_type; + s->range_table = &range_pcl816; break; case COMEDI_SUBD_DI: From ba93331e33c4600fe72bcbbe1bf8afb72b425098 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:47 -0700 Subject: [PATCH 0318/1375] staging: comedi: pcl818: remove 'rangelist_ao' from boardinfo The 'rangelist_ao' is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 4f195dbccba4..a000f742b0bf 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -266,7 +266,6 @@ struct pcl818_board { int n_dichan; int n_dochan; const struct comedi_lrange *ai_range_type; - const struct comedi_lrange *ao_range_type; unsigned int IRQbits; unsigned int DMAbits; int ai_maxdata; @@ -286,7 +285,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818l_l_ai, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -302,7 +300,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -318,7 +315,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -335,7 +331,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818hg_ai, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -352,7 +347,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -368,7 +362,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_unipolar5, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -382,7 +375,6 @@ static const struct pcl818_board boardtypes[] = { .n_dichan = 16, .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, - .ao_range_type = &range_unipolar5, .IRQbits = 0x00fc, .DMAbits = 0x0a, .ai_maxdata = 0xfff, @@ -1466,7 +1458,7 @@ no_dma: s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = board->n_aochan; s->maxdata = board->ao_maxdata; - s->range_table = board->ao_range_type; + s->range_table = &range_unipolar5; s->insn_read = pcl818_ao_insn_read; s->insn_write = pcl818_ao_insn_write; if (board->is_818) { From 27f3f4d411cb700a5514bfdf93929d1402683061 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:48 -0700 Subject: [PATCH 0319/1375] staging: comedi: pcl812: clarify dma channel request in pcl812_attach() All the board types that can do DMA can use DMA channels 3 or 1. Remove the 'DMAbits', which is a mask of the valid channels, from the boardinfo and replace it with a bit-field flag 'has_dma'. Refactor pcl812_attach() to use the new flag and remove the need for the goto. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 50 +++++++++++-------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 7b97dbe7276f..7f3d32080090 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -340,7 +340,7 @@ struct pcl812_board { unsigned int ai_ns_min; const struct comedi_lrange *rangelist_ai; unsigned int IRQbits; - unsigned char DMAbits; + unsigned int has_dma:1; unsigned char haveMPC508; }; @@ -356,7 +356,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 33000, .rangelist_ai = &range_bipolar10, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "pcl812pg", .board_type = boardPCL812PG, @@ -368,7 +368,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 33000, .rangelist_ai = &range_pcl812pg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "acl8112pg", .board_type = boardPCL812PG, @@ -380,7 +380,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_pcl812pg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "acl8112dg", .board_type = boardACL8112, @@ -393,7 +393,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, .haveMPC508 = 1, }, { .name = "acl8112hg", @@ -407,7 +407,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, .haveMPC508 = 1, }, { .name = "a821pgl", @@ -454,7 +454,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "a822pgh", .board_type = boardACL8112, @@ -467,7 +467,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "a823pgl", .board_type = boardACL8112, @@ -480,7 +480,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 8000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "a823pgh", .board_type = boardACL8112, @@ -493,7 +493,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 8000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, { .name = "pcl813", .board_type = boardPCL813, @@ -530,7 +530,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, .haveMPC508 = 1, }, { .name = "a826pg", @@ -544,7 +544,7 @@ static const struct pcl812_board boardtypes[] = { .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, - .DMAbits = 0x0a, + .has_dma = 1, }, }; @@ -1290,7 +1290,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct pcl812_board *board = comedi_board(dev); struct pcl812_private *devpriv; int ret, subdev; - unsigned int dma; unsigned long pages; struct comedi_subdevice *s; int n_subdevices; @@ -1310,24 +1309,18 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->irq = it->options[1]; } - dma = 0; - devpriv->dma = dma; - if (!dev->irq) - goto no_dma; /* if we haven't IRQ, we can't use DMA */ - if (board->DMAbits != 0) { /* board support DMA */ - dma = it->options[2]; - if (((1 << dma) & board->DMAbits) == 0) { - dev_err(dev->class_dev, - "DMA is out of allowed range, FAIL!\n"); - return -EINVAL; /* Bad DMA */ - } - ret = request_dma(dma, dev->board_name); + /* we need an IRQ to do DMA on channel 3 or 1 */ + if (dev->irq && board->has_dma && + (it->options[2] == 3 || it->options[2] == 1)) { + ret = request_dma(it->options[2], dev->board_name); if (ret) { dev_err(dev->class_dev, - "unable to allocate DMA %u, FAIL!\n", dma); - return -EBUSY; /* DMA isn't free */ + "unable to request DMA channel %d\n", + it->options[2]); + return -EBUSY; } - devpriv->dma = dma; + devpriv->dma = it->options[2]; + pages = 1; /* we want 8KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[0]) { @@ -1352,7 +1345,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmaptr[1] = virt_to_bus((void *)devpriv->dmabuf[1]); devpriv->hwdmasize[1] = PAGE_SIZE * (1 << pages); } -no_dma: n_subdevices = 0; if (board->n_aichan > 0) From ee34785cfd07e279b92f6fb1d44573118116841e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:49 -0700 Subject: [PATCH 0320/1375] staging: comedi: pcl816: clarify dma channel request in pcl816_attach() All the board types can do DMA using DMA channels 3 or 1. Remove the 'DMAbits', which is a mask of the valid channels, from the boardinfo. Refactor pcl816_attach() to remove the need for the goto. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 33 ++++++------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 5af687ab6b22..e67d24af9127 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -100,7 +100,6 @@ struct pcl816_board { int n_dochan; const struct comedi_lrange *ai_range_type; unsigned int IRQbits; - unsigned int DMAbits; int ai_maxdata; int ao_maxdata; int ai_chanlist; @@ -118,7 +117,6 @@ static const struct pcl816_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl816, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xffff, .ao_maxdata = 0xffff, .ai_chanlist = 1024, @@ -133,7 +131,6 @@ static const struct pcl816_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl816, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0x3fff, .ao_maxdata = 0x3fff, .ai_chanlist = 1024, @@ -866,7 +863,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct pcl816_board *board = comedi_board(dev); struct pcl816_private *devpriv; int ret; - unsigned int dma; unsigned long pages; /* int i; */ struct comedi_subdevice *s; @@ -894,30 +890,17 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */ devpriv->int816_mode = 0; /* mode of irq */ - /* grab our DMA */ - dma = 0; - devpriv->dma = dma; - if (!dev->irq) - goto no_dma; /* if we haven't IRQ, we can't use DMA */ - - if (board->DMAbits != 0) { /* board support DMA */ - dma = it->options[2]; - if (dma < 1) - goto no_dma; /* DMA disabled */ - - if (((1 << dma) & board->DMAbits) == 0) { - dev_err(dev->class_dev, - "DMA is out of allowed range, FAIL!\n"); - return -EINVAL; /* Bad DMA */ - } - ret = request_dma(dma, dev->board_name); + /* we need an IRQ to do DMA on channel 3 or 1 */ + if (dev->irq && (it->options[2] == 3 || it->options[2] == 1)) { + ret = request_dma(it->options[2], dev->board_name); if (ret) { dev_err(dev->class_dev, - "unable to allocate DMA %u, FAIL!\n", dma); - return -EBUSY; /* DMA isn't free */ + "unable to request DMA channel %d\n", + it->options[2]); + return -EBUSY; } + devpriv->dma = it->options[2]; - devpriv->dma = dma; pages = 2; /* we need 16KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); @@ -945,8 +928,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE; } -no_dma: - /* if (board->n_aochan > 0) subdevs[1] = COMEDI_SUBD_AO; if (board->n_dichan > 0) From 4ba4a2d307de7b60b47506346ad5e2bdf37e211a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:50 -0700 Subject: [PATCH 0321/1375] staging: comedi: pcl818: clarify dma channel request in pcl818_attach() All the board types that can do DMA can use DMA channels 3 or 1. Remove the 'DMAbits', which is a mask of the valid channels, from the boardinfo and replace it with a bit-field flag 'has_dma'. Refactor pcl818_attach() to use the new flag and remove the need for the goto. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 45 ++++++++++--------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index a000f742b0bf..9cb3e460c915 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -267,9 +267,9 @@ struct pcl818_board { int n_dochan; const struct comedi_lrange *ai_range_type; unsigned int IRQbits; - unsigned int DMAbits; int ai_maxdata; int ao_maxdata; + unsigned int has_dma:1; unsigned int has_fifo:1; int is_818; }; @@ -286,9 +286,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818l_l_ai, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, .is_818 = 1, }, { .name = "pcl818h", @@ -301,9 +301,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, .is_818 = 1, }, { .name = "pcl818hd", @@ -316,9 +316,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, .has_fifo = 1, .is_818 = 1, }, { @@ -332,9 +332,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818hg_ai, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, .has_fifo = 1, .is_818 = 1, }, { @@ -348,9 +348,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, .is_818 = 1, }, { .name = "pcl718", @@ -363,9 +363,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_unipolar5, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, }, { .name = "pcm3718", .n_ranges = 9, @@ -376,9 +376,9 @@ static const struct pcl818_board boardtypes[] = { .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, - .DMAbits = 0x0a, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, + .has_dma = 1, .is_818 = 1, }, }; @@ -1315,7 +1315,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct pcl818_board *board = comedi_board(dev); struct pcl818_private *devpriv; int ret; - int dma; unsigned long pages; struct comedi_subdevice *s; @@ -1347,24 +1346,18 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */ devpriv->ai_mode = 0; /* mode of irq */ - /* grab our DMA */ - dma = 0; - devpriv->dma = dma; - if (!dev->irq) - goto no_dma; /* if we haven't IRQ, we can't use DMA */ - if (board->DMAbits != 0) { /* board support DMA */ - dma = it->options[2]; - if (dma < 1) - goto no_dma; /* DMA disabled */ - if (((1 << dma) & board->DMAbits) == 0) { + /* we need an IRQ to do DMA on channel 3 or 1 */ + if (dev->irq && board->has_dma && + (it->options[2] == 3 || it->options[2] == 1)) { + ret = request_dma(it->options[2], dev->board_name); + if (ret) { dev_err(dev->class_dev, - "DMA is out of allowed range, FAIL!\n"); - return -EINVAL; /* Bad DMA */ + "unable to request DMA channel %d\n", + it->options[2]); + return -EBUSY; } - ret = request_dma(dma, dev->board_name); - if (ret) - return -EBUSY; /* DMA isn't free */ - devpriv->dma = dma; + devpriv->dma = it->options[2]; + pages = 2; /* we need 16KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[0]) @@ -1381,8 +1374,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE; } -no_dma: - ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; From fef20bff22ae3f27e9302266940a3e437984cd6a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:51 -0700 Subject: [PATCH 0322/1375] staging: comedi: pcl812: rename 'haveMPC508' in boardinfo Rename this CamelCase member in the boardinfo and change it to a bit- field flag. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 7f3d32080090..cbbadb82e653 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -341,7 +341,7 @@ struct pcl812_board { const struct comedi_lrange *rangelist_ai; unsigned int IRQbits; unsigned int has_dma:1; - unsigned char haveMPC508; + unsigned int has_mpc508_mux:1; }; static const struct pcl812_board boardtypes[] = { @@ -394,7 +394,7 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, .has_dma = 1, - .haveMPC508 = 1, + .has_mpc508_mux = 1, }, { .name = "acl8112hg", .board_type = boardACL8112, @@ -408,7 +408,7 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, .has_dma = 1, - .haveMPC508 = 1, + .has_mpc508_mux = 1, }, { .name = "a821pgl", .board_type = boardA821, @@ -531,7 +531,7 @@ static const struct pcl812_board boardtypes[] = { .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, .has_dma = 1, - .haveMPC508 = 1, + .has_mpc508_mux = 1, }, { .name = "a826pg", .board_type = boardACL8216, @@ -1401,7 +1401,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) else s->insn_read = pcl812_ai_insn_read; - devpriv->use_MPC = board->haveMPC508; + devpriv->use_MPC = board->has_mpc508_mux; if (dev->irq) { dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; From 9acf56f25ae157e3b78d1238671d103c360f83b4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:52 -0700 Subject: [PATCH 0323/1375] staging: comedi: pcl818: change 'is_818' in boardinfo to a bit-field Change this flag in the boardinfo into a bit-field. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 9cb3e460c915..e709e3c0a10b 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -271,7 +271,7 @@ struct pcl818_board { int ao_maxdata; unsigned int has_dma:1; unsigned int has_fifo:1; - int is_818; + unsigned int is_818:1; }; static const struct pcl818_board boardtypes[] = { From bb1aad5c3336802422ab66f1481531cf79aed3aa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:53 -0700 Subject: [PATCH 0324/1375] staging: comedi: pcl812: tidy up digital subdevice boardinfo For the board types that have digital inputs and outputs there are always 16 input channels and 16 output channels. Remove the 'n_dichan' and 'n_dochan' members in the boardinfo and replace them with a bit-field flag 'has_dio'. Refactor pcl812_attach() to use the new boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 60 +++++++++---------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index cbbadb82e653..cc8efa228b1e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -334,14 +334,13 @@ struct pcl812_board { int n_aichan; int n_aichan_diff; int n_aochan; - int n_dichan; - int n_dochan; int ai_maxdata; unsigned int ai_ns_min; const struct comedi_lrange *rangelist_ai; unsigned int IRQbits; unsigned int has_dma:1; unsigned int has_mpc508_mux:1; + unsigned int has_dio:1; }; static const struct pcl812_board boardtypes[] = { @@ -350,77 +349,71 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardPCL812, .n_aichan = 16, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 33000, .rangelist_ai = &range_bipolar10, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "pcl812pg", .board_type = boardPCL812PG, .n_aichan = 16, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 33000, .rangelist_ai = &range_pcl812pg_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "acl8112pg", .board_type = boardPCL812PG, .n_aichan = 16, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl812pg_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "acl8112dg", .board_type = boardACL8112, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, .has_dma = 1, .has_mpc508_mux = 1, + .has_dio = 1, }, { .name = "acl8112hg", .board_type = boardACL8112, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, .has_dma = 1, .has_mpc508_mux = 1, + .has_dio = 1, }, { .name = "a821pgl", .board_type = boardA821, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b_ai, .IRQbits = 0x000c, + .has_dio = 1, }, { .name = "a821pglnda", .board_type = boardA821, @@ -436,64 +429,59 @@ static const struct pcl812_board boardtypes[] = { .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_a821pgh_ai, .IRQbits = 0x000c, + .has_dio = 1, }, { .name = "a822pgl", .board_type = boardACL8112, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "a822pgh", .board_type = boardACL8112, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "a823pgl", .board_type = boardACL8112, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 8000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "a823pgh", .board_type = boardACL8112, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0x0fff, .ai_ns_min = 8000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, { .name = "pcl813", .board_type = boardPCL813, @@ -524,27 +512,25 @@ static const struct pcl812_board boardtypes[] = { .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0xffff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, .has_dma = 1, .has_mpc508_mux = 1, + .has_dio = 1, }, { .name = "a826pg", .board_type = boardACL8216, .n_aichan = 16, .n_aichan_diff = 8, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_maxdata = 0xffff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_dio = 1, }, }; @@ -1351,10 +1337,8 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) n_subdevices++; if (board->n_aochan > 0) n_subdevices++; - if (board->n_dichan > 0) - n_subdevices++; - if (board->n_dochan > 0) - n_subdevices++; + if (board->has_dio) + n_subdevices += 2; ret = comedi_alloc_subdevices(dev, n_subdevices); if (ret) @@ -1520,24 +1504,22 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) subdev++; } - /* digital input */ - if (board->n_dichan > 0) { + if (board->has_dio) { + /* Digital Input subdevice */ s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; - s->n_chan = board->n_dichan; + s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = pcl812_di_insn_bits; subdev++; - } - /* digital output */ - if (board->n_dochan > 0) { + /* Digital Output subdevice */ s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = board->n_dochan; + s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = pcl812_do_insn_bits; From 03d98e6c78c4de55220a8ad687b3c5df3b83f7d2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:54 -0700 Subject: [PATCH 0325/1375] staging: comedi: pcl818: all board types have digital inputs and outputs All the board types have 16 digital inputs and 16 digital outputs. Remove the 'n_dichan' and 'n_dochan' members in the boardinfo. Refactor pcl818_attach() to always setup these subdevices. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 50 +++++++------------------ 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index e709e3c0a10b..e206b78826a6 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -263,8 +263,6 @@ struct pcl818_board { int n_aichan_diff; unsigned int ns_min; int n_aochan; - int n_dichan; - int n_dochan; const struct comedi_lrange *ai_range_type; unsigned int IRQbits; int ai_maxdata; @@ -282,8 +280,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_diff = 8, .ns_min = 25000, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl818l_l_ai, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -297,8 +293,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -312,8 +306,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -328,8 +320,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl818hg_ai, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -344,8 +334,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -359,8 +347,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_diff = 8, .ns_min = 16000, .n_aochan = 2, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_unipolar5, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -372,8 +358,6 @@ static const struct pcl818_board boardtypes[] = { .n_aichan_se = 16, .n_aichan_diff = 8, .ns_min = 10000, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, .ai_maxdata = 0xfff, @@ -1465,29 +1449,23 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) } } + /* Digital Input subdevice */ s = &dev->subdevices[2]; - if (!board->n_dichan) { - s->type = COMEDI_SUBD_UNUSED; - } else { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = board->n_dichan; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = pcl818_di_insn_bits; - } + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = pcl818_di_insn_bits; + /* Digital Output subdevice */ s = &dev->subdevices[3]; - if (!board->n_dochan) { - s->type = COMEDI_SUBD_UNUSED; - } else { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = board->n_dochan; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = pcl818_do_insn_bits; - } + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = pcl818_do_insn_bits; /* select 1/10MHz oscilator */ if ((it->options[3] == 0) || (it->options[3] == 10)) From c1a6c5e120335082f01a222c346c88211541a856 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:55 -0700 Subject: [PATCH 0326/1375] staging: comedi: pcl816: all board types have digital inputs and outputs All the board types have 16 digital inputs and 16 digital outputs. Remove the 'n_dichan' and 'n_dochan' members in the boardinfo. The subdevice support code is currently incomplete in this driver. For now just tidy up the incomplete subdevice code in pcl816_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 26 +++++-------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index e67d24af9127..d1ca4b426de8 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -96,8 +96,6 @@ struct pcl816_board { int n_aichan; unsigned int ai_ns_min; int n_aochan; - int n_dichan; - int n_dochan; const struct comedi_lrange *ai_range_type; unsigned int IRQbits; int ai_maxdata; @@ -113,8 +111,6 @@ static const struct pcl816_board boardtypes[] = { .n_aichan = 16, .ai_ns_min = 10000, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl816, .IRQbits = 0x00fc, .ai_maxdata = 0xffff, @@ -127,8 +123,6 @@ static const struct pcl816_board boardtypes[] = { .n_aichan = 16, .ai_ns_min = 10000, .n_aochan = 1, - .n_dichan = 16, - .n_dochan = 16, .ai_range_type = &range_pcl816, .IRQbits = 0x00fc, .ai_maxdata = 0x3fff, @@ -928,14 +922,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE; } -/* if (board->n_aochan > 0) - subdevs[1] = COMEDI_SUBD_AO; - if (board->n_dichan > 0) - subdevs[2] = COMEDI_SUBD_DI; - if (board->n_dochan > 0) - subdevs[3] = COMEDI_SUBD_DO; -*/ - ret = comedi_alloc_subdevices(dev, 1); if (ret) return ret; @@ -962,7 +948,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) } #if 0 -case COMEDI_SUBD_AO: + subdevs[1] = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = board->n_aochan; s->maxdata = board->ao_maxdata; @@ -970,19 +956,17 @@ case COMEDI_SUBD_AO: s->range_table = &range_pcl816; break; -case COMEDI_SUBD_DI: + subdevs[2] = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; - s->n_chan = board->n_dichan; + s->n_chan = 16; s->maxdata = 1; - s->len_chanlist = board->n_dichan; s->range_table = &range_digital; break; -case COMEDI_SUBD_DO: + subdevs[3] = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = board->n_dochan; + s->n_chan = 16; s->maxdata = 1; - s->len_chanlist = board->n_dochan; s->range_table = &range_digital; break; #endif From 8f10ecc1c3274b8e8fdf1644504cc720f1970771 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:56 -0700 Subject: [PATCH 0327/1375] staging: comedi: pcl812: factor analog input range selection out of (*attach) The analog input subdevice range is setup in this driver based on a config option passed by the user. Factor the code that sets the range_table out of pcl812_attach() to clarify the (*attach). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 172 +++++++++++++----------- 1 file changed, 93 insertions(+), 79 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index cc8efa228b1e..1d8366e97ebb 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1271,6 +1271,96 @@ static void pcl812_reset(struct comedi_device *dev) udelay(5); } +static void pcl812_set_ai_range_table(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_devconfig *it) +{ + const struct pcl812_board *board = comedi_board(dev); + struct pcl812_private *devpriv = dev->private; + + /* default to the range table from the boardinfo */ + s->range_table = board->rangelist_ai; + + /* now check the user config option based on the boardtype */ + switch (board->board_type) { + case boardPCL812PG: + if (it->options[4] == 1) + s->range_table = &range_pcl812pg2_ai; + break; + case boardPCL812: + switch (it->options[4]) { + case 0: + s->range_table = &range_bipolar10; + break; + case 1: + s->range_table = &range_bipolar5; + break; + case 2: + s->range_table = &range_bipolar2_5; + break; + case 3: + s->range_table = &range812_bipolar1_25; + break; + case 4: + s->range_table = &range812_bipolar0_625; + break; + case 5: + s->range_table = &range812_bipolar0_3125; + break; + default: + s->range_table = &range_bipolar10; + break; + } + break; + case boardPCL813B: + if (it->options[1] == 1) + s->range_table = &range_pcl813b2_ai; + break; + case boardISO813: + switch (it->options[1]) { + case 0: + s->range_table = &range_iso813_1_ai; + break; + case 1: + s->range_table = &range_iso813_1_2_ai; + break; + case 2: + s->range_table = &range_iso813_2_ai; + devpriv->range_correction = 1; + break; + case 3: + s->range_table = &range_iso813_2_2_ai; + devpriv->range_correction = 1; + break; + default: + s->range_table = &range_iso813_1_ai; + break; + } + break; + case boardACL8113: + switch (it->options[1]) { + case 0: + s->range_table = &range_acl8113_1_ai; + break; + case 1: + s->range_table = &range_acl8113_1_2_ai; + break; + case 2: + s->range_table = &range_acl8113_2_ai; + devpriv->range_correction = 1; + break; + case 3: + s->range_table = &range_acl8113_2_2_ai; + devpriv->range_correction = 1; + break; + default: + s->range_table = &range_acl8113_1_ai; + break; + } + break; + } +} + static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl812_board *board = comedi_board(dev); @@ -1379,7 +1469,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) break; } s->maxdata = board->ai_maxdata; - s->range_table = board->rangelist_ai; + + pcl812_set_ai_range_table(dev, s, it); + if (board->board_type == boardACL8216) s->insn_read = acl8216_ai_insn_read; else @@ -1395,84 +1487,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->poll = pcl812_ai_poll; s->cancel = pcl812_ai_cancel; } - switch (board->board_type) { - case boardPCL812PG: - if (it->options[4] == 1) - s->range_table = &range_pcl812pg2_ai; - break; - case boardPCL812: - switch (it->options[4]) { - case 0: - s->range_table = &range_bipolar10; - break; - case 1: - s->range_table = &range_bipolar5; - break; - case 2: - s->range_table = &range_bipolar2_5; - break; - case 3: - s->range_table = &range812_bipolar1_25; - break; - case 4: - s->range_table = &range812_bipolar0_625; - break; - case 5: - s->range_table = &range812_bipolar0_3125; - break; - default: - s->range_table = &range_bipolar10; - break; - } - break; - break; - case boardPCL813B: - if (it->options[1] == 1) - s->range_table = &range_pcl813b2_ai; - break; - case boardISO813: - switch (it->options[1]) { - case 0: - s->range_table = &range_iso813_1_ai; - break; - case 1: - s->range_table = &range_iso813_1_2_ai; - break; - case 2: - s->range_table = &range_iso813_2_ai; - devpriv->range_correction = 1; - break; - case 3: - s->range_table = &range_iso813_2_2_ai; - devpriv->range_correction = 1; - break; - default: - s->range_table = &range_iso813_1_ai; - break; - } - break; - case boardACL8113: - switch (it->options[1]) { - case 0: - s->range_table = &range_acl8113_1_ai; - break; - case 1: - s->range_table = &range_acl8113_1_2_ai; - break; - case 2: - s->range_table = &range_acl8113_2_ai; - devpriv->range_correction = 1; - break; - case 3: - s->range_table = &range_acl8113_2_2_ai; - devpriv->range_correction = 1; - break; - default: - s->range_table = &range_acl8113_1_ai; - break; - } - break; - } subdev++; } From f39b8ccf7e02277d94ae67210fd71225ee4e53f5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:57 -0700 Subject: [PATCH 0328/1375] staging: comedi: pcl818: factor analog input range selection out of (*attach) The analog input subdevice range is setup in this driver based on a config option passed by the user. Factor the code that sets the range_table out of pcl818_attach() to clarify the (*attach). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 92 +++++++++++++++---------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index e206b78826a6..000df80a689d 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -1294,6 +1294,57 @@ static void pcl818_reset(struct comedi_device *dev) } } +static void pcl818_set_ai_range_table(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_devconfig *it) +{ + const struct pcl818_board *board = comedi_board(dev); + + /* default to the range table from the boardinfo */ + s->range_table = board->ai_range_type; + + /* now check the user config option based on the boardtype */ + if (board->is_818) { + if (it->options[4] == 1 || it->options[4] == 10) { + /* secondary range list jumper selectable */ + s->range_table = &range_pcl818l_h_ai; + } + } else { + switch (it->options[4]) { + case 0: + s->range_table = &range_bipolar10; + break; + case 1: + s->range_table = &range_bipolar5; + break; + case 2: + s->range_table = &range_bipolar2_5; + break; + case 3: + s->range_table = &range718_bipolar1; + break; + case 4: + s->range_table = &range718_bipolar0_5; + break; + case 6: + s->range_table = &range_unipolar10; + break; + case 7: + s->range_table = &range_unipolar5; + break; + case 8: + s->range_table = &range718_unipolar2; + break; + case 9: + s->range_table = &range718_unipolar1; + break; + default: + s->range_table = &range_unknown; + break; + } + } +} + static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl818_board *board = comedi_board(dev); @@ -1376,7 +1427,9 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags |= SDF_DIFF; } s->maxdata = board->ai_maxdata; - s->range_table = board->ai_range_type; + + pcl818_set_ai_range_table(dev, s, it); + s->insn_read = pcl818_ai_insn_read; if (dev->irq) { dev->read_subdev = s; @@ -1386,43 +1439,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->do_cmd = ai_cmd; s->cancel = pcl818_ai_cancel; } - if (board->is_818) { - if ((it->options[4] == 1) || (it->options[4] == 10)) - s->range_table = &range_pcl818l_h_ai; /* secondary range list jumper selectable */ - } else { - switch (it->options[4]) { - case 0: - s->range_table = &range_bipolar10; - break; - case 1: - s->range_table = &range_bipolar5; - break; - case 2: - s->range_table = &range_bipolar2_5; - break; - case 3: - s->range_table = &range718_bipolar1; - break; - case 4: - s->range_table = &range718_bipolar0_5; - break; - case 6: - s->range_table = &range_unipolar10; - break; - case 7: - s->range_table = &range_unipolar5; - break; - case 8: - s->range_table = &range718_unipolar2; - break; - case 9: - s->range_table = &range718_unipolar1; - break; - default: - s->range_table = &range_unknown; - break; - } - } } s = &dev->subdevices[1]; From 78da4c5698110a77b5a9025ff3f03304990850e6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:58 -0700 Subject: [PATCH 0329/1375] staging: comedi: pcl812: all board types have analog inputs All the boards supported by this driver have 16 or 32 analog input channels. Remove the unnecessary check in pcl812_attach() to reduce the indent level of the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 104 ++++++++++++------------ 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 1d8366e97ebb..4909a106b2ce 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1422,9 +1422,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmasize[1] = PAGE_SIZE * (1 << pages); } - n_subdevices = 0; - if (board->n_aichan > 0) - n_subdevices++; + n_subdevices = 1; /* all boardtypes have analog inputs */ if (board->n_aochan > 0) n_subdevices++; if (board->has_dio) @@ -1436,59 +1434,59 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) subdev = 0; - /* analog input */ - if (board->n_aichan > 0) { - s = &dev->subdevices[subdev]; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE; - switch (board->board_type) { - case boardA821: - if (it->options[2] == 1) { - s->n_chan = board->n_aichan_diff; - s->subdev_flags |= SDF_DIFF; - devpriv->use_diff = 1; - } else { - s->n_chan = board->n_aichan; - s->subdev_flags |= SDF_GROUND; - } - break; - case boardACL8112: - case boardACL8216: - if (it->options[4] == 1) { - s->n_chan = board->n_aichan_diff; - s->subdev_flags |= SDF_DIFF; - devpriv->use_diff = 1; - } else { - s->n_chan = board->n_aichan; - s->subdev_flags |= SDF_GROUND; - } - break; - default: - s->n_chan = board->n_aichan; - s->subdev_flags |= SDF_GROUND; - break; + /* Analog Input subdevice */ + s = &dev->subdevices[subdev]; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE; + switch (board->board_type) { + case boardA821: + if (it->options[2] == 1) { + s->n_chan = board->n_aichan_diff; + s->subdev_flags |= SDF_DIFF; + devpriv->use_diff = 1; + } else { + s->n_chan = board->n_aichan; + s->subdev_flags |= SDF_GROUND; } - s->maxdata = board->ai_maxdata; - - pcl812_set_ai_range_table(dev, s, it); - - if (board->board_type == boardACL8216) - s->insn_read = acl8216_ai_insn_read; - else - s->insn_read = pcl812_ai_insn_read; - - devpriv->use_MPC = board->has_mpc508_mux; - if (dev->irq) { - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = MAX_CHANLIST_LEN; - s->do_cmdtest = pcl812_ai_cmdtest; - s->do_cmd = pcl812_ai_cmd; - s->poll = pcl812_ai_poll; - s->cancel = pcl812_ai_cancel; + break; + case boardACL8112: + case boardACL8216: + if (it->options[4] == 1) { + s->n_chan = board->n_aichan_diff; + s->subdev_flags |= SDF_DIFF; + devpriv->use_diff = 1; + } else { + s->n_chan = board->n_aichan; + s->subdev_flags |= SDF_GROUND; } - subdev++; + break; + default: + s->n_chan = board->n_aichan; + s->subdev_flags |= SDF_GROUND; + break; } + s->maxdata = board->ai_maxdata; + + pcl812_set_ai_range_table(dev, s, it); + + if (board->board_type == boardACL8216) + s->insn_read = acl8216_ai_insn_read; + else + s->insn_read = pcl812_ai_insn_read; + + if (dev->irq) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = MAX_CHANLIST_LEN; + s->do_cmdtest = pcl812_ai_cmdtest; + s->do_cmd = pcl812_ai_cmd; + s->poll = pcl812_ai_poll; + s->cancel = pcl812_ai_cancel; + } + + devpriv->use_MPC = board->has_mpc508_mux; + + subdev++; /* analog output */ if (board->n_aochan > 0) { From 1ddd22c0dfdc1f03e22acae71a39b6be347568be Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:26:59 -0700 Subject: [PATCH 0330/1375] staging: comedi: pcl816: all board types have 16 analog inputs All the boards supported by this driver have 16 analog input channels. Remove the 'n_aichan' member from the boardinfo and refactor pcl816_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 35 ++++++++++--------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index d1ca4b426de8..d64ed5e26858 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -93,7 +93,6 @@ static const struct comedi_lrange range_pcl816 = { struct pcl816_board { const char *name; int n_ranges; - int n_aichan; unsigned int ai_ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; @@ -108,7 +107,6 @@ static const struct pcl816_board boardtypes[] = { { .name = "pcl816", .n_ranges = 8, - .n_aichan = 16, .ai_ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl816, @@ -120,7 +118,6 @@ static const struct pcl816_board boardtypes[] = { }, { .name = "pcl814b", .n_ranges = 8, - .n_aichan = 16, .ai_ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl816, @@ -927,24 +924,20 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) return ret; s = &dev->subdevices[0]; - if (board->n_aichan > 0) { - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_CMD_READ | SDF_DIFF; - s->n_chan = board->n_aichan; - s->maxdata = board->ai_maxdata; - s->range_table = board->ai_range_type; - s->insn_read = pcl816_ai_insn_read; - if (dev->irq) { - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = board->ai_chanlist; - s->do_cmdtest = pcl816_ai_cmdtest; - s->do_cmd = pcl816_ai_cmd; - s->poll = pcl816_ai_poll; - s->cancel = pcl816_ai_cancel; - } - } else { - s->type = COMEDI_SUBD_UNUSED; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_CMD_READ | SDF_DIFF; + s->n_chan = 16; + s->maxdata = board->ai_maxdata; + s->range_table = board->ai_range_type; + s->insn_read = pcl816_ai_insn_read; + if (dev->irq) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = board->ai_chanlist; + s->do_cmdtest = pcl816_ai_cmdtest; + s->do_cmd = pcl816_ai_cmd; + s->poll = pcl816_ai_poll; + s->cancel = pcl816_ai_cancel; } #if 0 From 9c06c4e39671ded54036075eaf0aae9404954b06 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:00 -0700 Subject: [PATCH 0331/1375] staging: comedi: pcl818: all board types have analog inputs All the boards supported by this driver have 16 single-ended analog input channels. The boards can also be configued to give 8 differential inputs. Remove the 'n_aichan_se' and 'n_aichan_diff' members from the boardinfo and refactor pcl818_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 56 ++++++++----------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 000df80a689d..4f280268fd6c 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -259,8 +259,6 @@ static const struct comedi_lrange range718_unipolar1 = { struct pcl818_board { const char *name; int n_ranges; - int n_aichan_se; - int n_aichan_diff; unsigned int ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; @@ -276,8 +274,6 @@ static const struct pcl818_board boardtypes[] = { { .name = "pcl818l", .n_ranges = 4, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 25000, .n_aochan = 1, .ai_range_type = &range_pcl818l_l_ai, @@ -289,8 +285,6 @@ static const struct pcl818_board boardtypes[] = { }, { .name = "pcl818h", .n_ranges = 9, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, @@ -302,8 +296,6 @@ static const struct pcl818_board boardtypes[] = { }, { .name = "pcl818hd", .n_ranges = 9, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, @@ -316,8 +308,6 @@ static const struct pcl818_board boardtypes[] = { }, { .name = "pcl818hg", .n_ranges = 12, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818hg_ai, @@ -330,8 +320,6 @@ static const struct pcl818_board boardtypes[] = { }, { .name = "pcl818", .n_ranges = 9, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 10000, .n_aochan = 2, .ai_range_type = &range_pcl818h_ai, @@ -343,8 +331,6 @@ static const struct pcl818_board boardtypes[] = { }, { .name = "pcl718", .n_ranges = 1, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 16000, .n_aochan = 2, .ai_range_type = &range_unipolar5, @@ -355,8 +341,6 @@ static const struct pcl818_board boardtypes[] = { }, { .name = "pcm3718", .n_ranges = 9, - .n_aichan_se = 16, - .n_aichan_diff = 8, .ns_min = 10000, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, @@ -1414,31 +1398,27 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) return ret; s = &dev->subdevices[0]; - if (!board->n_aichan_se) { - s->type = COMEDI_SUBD_UNUSED; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE; + if (check_single_ended(dev->iobase)) { + s->n_chan = 16; + s->subdev_flags |= SDF_COMMON | SDF_GROUND; } else { - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE; - if (check_single_ended(dev->iobase)) { - s->n_chan = board->n_aichan_se; - s->subdev_flags |= SDF_COMMON | SDF_GROUND; - } else { - s->n_chan = board->n_aichan_diff; - s->subdev_flags |= SDF_DIFF; - } - s->maxdata = board->ai_maxdata; + s->n_chan = 8; + s->subdev_flags |= SDF_DIFF; + } + s->maxdata = board->ai_maxdata; - pcl818_set_ai_range_table(dev, s, it); + pcl818_set_ai_range_table(dev, s, it); - s->insn_read = pcl818_ai_insn_read; - if (dev->irq) { - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = s->n_chan; - s->do_cmdtest = ai_cmdtest; - s->do_cmd = ai_cmd; - s->cancel = pcl818_ai_cancel; - } + s->insn_read = pcl818_ai_insn_read; + if (dev->irq) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = s->n_chan; + s->do_cmdtest = ai_cmdtest; + s->do_cmd = ai_cmd; + s->cancel = pcl818_ai_cancel; } s = &dev->subdevices[1]; From 9b4dd5d1afb0dea80ab4274433b25a1c0598e855 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:01 -0700 Subject: [PATCH 0332/1375] staging: comedi: pcl812: tidy up differential ai user option Some of the boards supported by this driver can do differential analog input when configureg with jumpers on the board. When diff. ai is used the number of input channels is half the single-ended number of channels. The user specifies the analog input mode for these boards when attaching to the driver by using a configuration option. Remove the unnecessary 'n_aichan_diff' member from the boardinfo. Add a comment for the boards that can do differential ai. Refactor pcl812_attach() to parse the user option before setting up the subdevices. We can then use the 'use_diff' flag to determine if the ai is single-ended or differential and set the subdev_flags and n_chan. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 77 ++++++++++--------------- 1 file changed, 29 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 4909a106b2ce..54bbd9e59261 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -332,7 +332,6 @@ struct pcl812_board { const char *name; int board_type; int n_aichan; - int n_aichan_diff; int n_aochan; int ai_maxdata; unsigned int ai_ns_min; @@ -380,8 +379,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "acl8112dg", .board_type = boardACL8112, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, @@ -393,8 +391,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "acl8112hg", .board_type = boardACL8112, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, @@ -406,8 +403,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a821pgl", .board_type = boardA821, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 1, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, @@ -417,8 +413,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a821pglnda", .board_type = boardA821, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b_ai, @@ -426,8 +421,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a821pgh", .board_type = boardA821, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 1, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, @@ -437,8 +431,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a822pgl", .board_type = boardACL8112, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, @@ -449,8 +442,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a822pgh", .board_type = boardACL8112, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0x0fff, .ai_ns_min = 10000, @@ -461,8 +453,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a823pgl", .board_type = boardACL8112, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0x0fff, .ai_ns_min = 8000, @@ -473,8 +464,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a823pgh", .board_type = boardACL8112, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0x0fff, .ai_ns_min = 8000, @@ -509,8 +499,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "acl8216", .board_type = boardACL8216, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0xffff, .ai_ns_min = 10000, @@ -522,8 +511,7 @@ static const struct pcl812_board boardtypes[] = { }, { .name = "a826pg", .board_type = boardACL8216, - .n_aichan = 16, - .n_aichan_diff = 8, + .n_aichan = 16, /* 8 differential */ .n_aochan = 2, .ai_maxdata = 0xffff, .ai_ns_min = 10000, @@ -1422,6 +1410,19 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmasize[1] = PAGE_SIZE * (1 << pages); } + /* differential analog inputs? */ + switch (board->board_type) { + case boardA821: + if (it->options[2] == 1) + devpriv->use_diff = 1; + break; + case boardACL8112: + case boardACL8216: + if (it->options[4] == 1) + devpriv->use_diff = 1; + break; + } + n_subdevices = 1; /* all boardtypes have analog inputs */ if (board->n_aochan > 0) n_subdevices++; @@ -1438,32 +1439,12 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE; - switch (board->board_type) { - case boardA821: - if (it->options[2] == 1) { - s->n_chan = board->n_aichan_diff; - s->subdev_flags |= SDF_DIFF; - devpriv->use_diff = 1; - } else { - s->n_chan = board->n_aichan; - s->subdev_flags |= SDF_GROUND; - } - break; - case boardACL8112: - case boardACL8216: - if (it->options[4] == 1) { - s->n_chan = board->n_aichan_diff; - s->subdev_flags |= SDF_DIFF; - devpriv->use_diff = 1; - } else { - s->n_chan = board->n_aichan; - s->subdev_flags |= SDF_GROUND; - } - break; - default: - s->n_chan = board->n_aichan; + if (devpriv->use_diff) { + s->subdev_flags |= SDF_DIFF; + s->n_chan = board->n_aichan / 2; + } else { s->subdev_flags |= SDF_GROUND; - break; + s->n_chan = board->n_aichan; } s->maxdata = board->ai_maxdata; From 90c6328e6c4ab5b753e8cdb12e7455f911ea3be8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:02 -0700 Subject: [PATCH 0333/1375] staging: comedi: pcl816: remove 'n_ranges' from boardinfo This member in the boardinfo is not used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index d64ed5e26858..b2d857d3acca 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -92,7 +92,6 @@ static const struct comedi_lrange range_pcl816 = { struct pcl816_board { const char *name; - int n_ranges; unsigned int ai_ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; @@ -106,7 +105,6 @@ struct pcl816_board { static const struct pcl816_board boardtypes[] = { { .name = "pcl816", - .n_ranges = 8, .ai_ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl816, @@ -117,7 +115,6 @@ static const struct pcl816_board boardtypes[] = { .ao_chanlist = 1, }, { .name = "pcl814b", - .n_ranges = 8, .ai_ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl816, From bffeff2d2c858bad9e97517cc4936fb05ce197d6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:03 -0700 Subject: [PATCH 0334/1375] staging: comedi: pcl818: remove 'n_ranges' from boardinfo This member in the boardinfo is not used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 4f280268fd6c..ded1bf8dbe3e 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -258,7 +258,6 @@ static const struct comedi_lrange range718_unipolar1 = { struct pcl818_board { const char *name; - int n_ranges; unsigned int ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; @@ -273,7 +272,6 @@ struct pcl818_board { static const struct pcl818_board boardtypes[] = { { .name = "pcl818l", - .n_ranges = 4, .ns_min = 25000, .n_aochan = 1, .ai_range_type = &range_pcl818l_l_ai, @@ -284,7 +282,6 @@ static const struct pcl818_board boardtypes[] = { .is_818 = 1, }, { .name = "pcl818h", - .n_ranges = 9, .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, @@ -295,7 +292,6 @@ static const struct pcl818_board boardtypes[] = { .is_818 = 1, }, { .name = "pcl818hd", - .n_ranges = 9, .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, @@ -307,7 +303,6 @@ static const struct pcl818_board boardtypes[] = { .is_818 = 1, }, { .name = "pcl818hg", - .n_ranges = 12, .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818hg_ai, @@ -319,7 +314,6 @@ static const struct pcl818_board boardtypes[] = { .is_818 = 1, }, { .name = "pcl818", - .n_ranges = 9, .ns_min = 10000, .n_aochan = 2, .ai_range_type = &range_pcl818h_ai, @@ -330,7 +324,6 @@ static const struct pcl818_board boardtypes[] = { .is_818 = 1, }, { .name = "pcl718", - .n_ranges = 1, .ns_min = 16000, .n_aochan = 2, .ai_range_type = &range_unipolar5, @@ -340,7 +333,6 @@ static const struct pcl818_board boardtypes[] = { .has_dma = 1, }, { .name = "pcm3718", - .n_ranges = 9, .ns_min = 10000, .ai_range_type = &range_pcl818h_ai, .IRQbits = 0x00fc, From f5fafc976ffca0350bd7114c213c9f65ec23d6cd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:04 -0700 Subject: [PATCH 0335/1375] staging: comedi: pcl816: remove 'ao_chanlist' from boardinfo This member in the boardinfo is the same for all board types. Remove it. The comedi core will initalize the subdevice len_chanlist to 1 if it is not set by the driver so remove the unnecessary initialization. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index b2d857d3acca..70f5c78495de 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -99,7 +99,6 @@ struct pcl816_board { int ai_maxdata; int ao_maxdata; int ai_chanlist; - int ao_chanlist; }; static const struct pcl816_board boardtypes[] = { @@ -112,7 +111,6 @@ static const struct pcl816_board boardtypes[] = { .ai_maxdata = 0xffff, .ao_maxdata = 0xffff, .ai_chanlist = 1024, - .ao_chanlist = 1, }, { .name = "pcl814b", .ai_ns_min = 10000, @@ -122,7 +120,6 @@ static const struct pcl816_board boardtypes[] = { .ai_maxdata = 0x3fff, .ao_maxdata = 0x3fff, .ai_chanlist = 1024, - .ao_chanlist = 1, }, }; @@ -942,7 +939,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = board->n_aochan; s->maxdata = board->ao_maxdata; - s->len_chanlist = board->ao_chanlist; s->range_table = &range_pcl816; break; From 8cfda3f8764136a5a3f17078e99c073a3d377c1e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:06 -0700 Subject: [PATCH 0336/1375] staging: comedi: pcl816: remove 'ai_range_type' from boardinfo All the board types use the same analog input range_table. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 70f5c78495de..7e7c30247eef 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -94,7 +94,6 @@ struct pcl816_board { const char *name; unsigned int ai_ns_min; int n_aochan; - const struct comedi_lrange *ai_range_type; unsigned int IRQbits; int ai_maxdata; int ao_maxdata; @@ -106,7 +105,6 @@ static const struct pcl816_board boardtypes[] = { .name = "pcl816", .ai_ns_min = 10000, .n_aochan = 1, - .ai_range_type = &range_pcl816, .IRQbits = 0x00fc, .ai_maxdata = 0xffff, .ao_maxdata = 0xffff, @@ -115,7 +113,6 @@ static const struct pcl816_board boardtypes[] = { .name = "pcl814b", .ai_ns_min = 10000, .n_aochan = 1, - .ai_range_type = &range_pcl816, .IRQbits = 0x00fc, .ai_maxdata = 0x3fff, .ao_maxdata = 0x3fff, @@ -922,7 +919,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_CMD_READ | SDF_DIFF; s->n_chan = 16; s->maxdata = board->ai_maxdata; - s->range_table = board->ai_range_type; + s->range_table = &range_pcl816; s->insn_read = pcl816_ai_insn_read; if (dev->irq) { dev->read_subdev = s; From 8356d4b4f444fa5745f042527043a2ad3a5bf685 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:10 -0700 Subject: [PATCH 0337/1375] staging: comedi: pcl818: clarify irq request in pcl818_attach() All the board types can use IRQ 2-7 for async command support. Remove the 'IRQbits', which is a mask of the valid IRQs, from the boardinfo and refactor pcl818_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index ded1bf8dbe3e..e3a2579eecf2 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -261,7 +261,6 @@ struct pcl818_board { unsigned int ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; - unsigned int IRQbits; int ai_maxdata; int ao_maxdata; unsigned int has_dma:1; @@ -275,7 +274,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 25000, .n_aochan = 1, .ai_range_type = &range_pcl818l_l_ai, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -285,7 +283,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -295,7 +292,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -306,7 +302,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818hg_ai, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -317,7 +312,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 2, .ai_range_type = &range_pcl818h_ai, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -327,7 +321,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 16000, .n_aochan = 2, .ai_range_type = &range_unipolar5, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -335,7 +328,6 @@ static const struct pcl818_board boardtypes[] = { .name = "pcm3718", .ns_min = 10000, .ai_range_type = &range_pcl818h_ai, - .IRQbits = 0x00fc, .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, @@ -1347,7 +1339,8 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) return -EIO; } - if ((1 << it->options[1]) & board->IRQbits) { + /* we can use IRQ 2-7 for async command support */ + if (it->options[1] >= 2 && it->options[1] <= 7) { ret = request_irq(it->options[1], interrupt_pcl818, 0, dev->board_name, dev); if (ret == 0) From bca1b5944db3af9f7e04b5d3917f789ad4cc3960 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:11 -0700 Subject: [PATCH 0338/1375] staging: comedi: pcl818: remove 'ai_maxdata' from boardinfo All the board types have 12-bit analog inputs. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index e3a2579eecf2..4d452d20402d 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -261,7 +261,6 @@ struct pcl818_board { unsigned int ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; - int ai_maxdata; int ao_maxdata; unsigned int has_dma:1; unsigned int has_fifo:1; @@ -274,7 +273,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 25000, .n_aochan = 1, .ai_range_type = &range_pcl818l_l_ai, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, @@ -283,7 +281,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, @@ -292,7 +289,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, .has_fifo = 1, @@ -302,7 +298,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818hg_ai, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, .has_fifo = 1, @@ -312,7 +307,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 2, .ai_range_type = &range_pcl818h_ai, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, @@ -321,14 +315,12 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 16000, .n_aochan = 2, .ai_range_type = &range_unipolar5, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, }, { .name = "pcm3718", .ns_min = 10000, .ai_range_type = &range_pcl818h_ai, - .ai_maxdata = 0xfff, .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, @@ -1392,7 +1384,7 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->n_chan = 8; s->subdev_flags |= SDF_DIFF; } - s->maxdata = board->ai_maxdata; + s->maxdata = 0x0fff; pcl818_set_ai_range_table(dev, s, it); From 2bfe3eb76fa427492924f48a32bf230bfb88caf8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:12 -0700 Subject: [PATCH 0339/1375] staging: comedi: pcl818: remove 'ao_maxdata' from boardinfo All the board types have 12-bit analog outputs. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 4d452d20402d..2b8e7e0d2c75 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -261,7 +261,6 @@ struct pcl818_board { unsigned int ns_min; int n_aochan; const struct comedi_lrange *ai_range_type; - int ao_maxdata; unsigned int has_dma:1; unsigned int has_fifo:1; unsigned int is_818:1; @@ -273,7 +272,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 25000, .n_aochan = 1, .ai_range_type = &range_pcl818l_l_ai, - .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, }, { @@ -281,7 +279,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, - .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, }, { @@ -289,7 +286,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818h_ai, - .ao_maxdata = 0xfff, .has_dma = 1, .has_fifo = 1, .is_818 = 1, @@ -298,7 +294,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 1, .ai_range_type = &range_pcl818hg_ai, - .ao_maxdata = 0xfff, .has_dma = 1, .has_fifo = 1, .is_818 = 1, @@ -307,7 +302,6 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 10000, .n_aochan = 2, .ai_range_type = &range_pcl818h_ai, - .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, }, { @@ -315,13 +309,11 @@ static const struct pcl818_board boardtypes[] = { .ns_min = 16000, .n_aochan = 2, .ai_range_type = &range_unipolar5, - .ao_maxdata = 0xfff, .has_dma = 1, }, { .name = "pcm3718", .ns_min = 10000, .ai_range_type = &range_pcl818h_ai, - .ao_maxdata = 0xfff, .has_dma = 1, .is_818 = 1, }, @@ -1405,7 +1397,7 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = board->n_aochan; - s->maxdata = board->ao_maxdata; + s->maxdata = 0x0fff; s->range_table = &range_unipolar5; s->insn_read = pcl818_ao_insn_read; s->insn_write = pcl818_ao_insn_write; From f8bf22a8e087225fc6a294170006cb409ae1a8ae Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:13 -0700 Subject: [PATCH 0340/1375] staging: comedi: pcl812: remove 'ai_maxdata' from boardinfo Most of the board types supported by this driver have 12-bit analog inputs. Two of them, the acl8216 and a826pg, have 16-bit analog inputs. Remove the 'ai_maxdata' member from the boardinfo and replace it with a bit-field flag 'has_16bit_ai'. Refactor pcl812_attach() to use this new boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 54bbd9e59261..4ecbb297dcb7 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -333,11 +333,11 @@ struct pcl812_board { int board_type; int n_aichan; int n_aochan; - int ai_maxdata; unsigned int ai_ns_min; const struct comedi_lrange *rangelist_ai; unsigned int IRQbits; unsigned int has_dma:1; + unsigned int has_16bit_ai:1; unsigned int has_mpc508_mux:1; unsigned int has_dio:1; }; @@ -348,7 +348,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardPCL812, .n_aichan = 16, .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 33000, .rangelist_ai = &range_bipolar10, .IRQbits = 0xdcfc, @@ -359,7 +358,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardPCL812PG, .n_aichan = 16, .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 33000, .rangelist_ai = &range_pcl812pg_ai, .IRQbits = 0xdcfc, @@ -370,7 +368,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardPCL812PG, .n_aichan = 16, .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl812pg_ai, .IRQbits = 0xdcfc, @@ -381,7 +378,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8112, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, @@ -393,7 +389,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8112, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, @@ -405,7 +400,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardA821, .n_aichan = 16, /* 8 differential */ .n_aochan = 1, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b_ai, .IRQbits = 0x000c, @@ -414,7 +408,6 @@ static const struct pcl812_board boardtypes[] = { .name = "a821pglnda", .board_type = boardA821, .n_aichan = 16, /* 8 differential */ - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b_ai, .IRQbits = 0x000c, @@ -423,7 +416,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardA821, .n_aichan = 16, /* 8 differential */ .n_aochan = 1, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_a821pgh_ai, .IRQbits = 0x000c, @@ -433,7 +425,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8112, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, @@ -444,7 +435,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8112, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 10000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, @@ -455,7 +445,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8112, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 8000, .rangelist_ai = &range_acl8112dg_ai, .IRQbits = 0xdcfc, @@ -466,7 +455,6 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8112, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0x0fff, .ai_ns_min = 8000, .rangelist_ai = &range_acl8112hg_ai, .IRQbits = 0xdcfc, @@ -476,36 +464,32 @@ static const struct pcl812_board boardtypes[] = { .name = "pcl813", .board_type = boardPCL813, .n_aichan = 32, - .ai_maxdata = 0x0fff, .rangelist_ai = &range_pcl813b_ai, }, { .name = "pcl813b", .board_type = boardPCL813B, .n_aichan = 32, - .ai_maxdata = 0x0fff, .rangelist_ai = &range_pcl813b_ai, }, { .name = "acl8113", .board_type = boardACL8113, .n_aichan = 32, - .ai_maxdata = 0x0fff, .rangelist_ai = &range_acl8113_1_ai, }, { .name = "iso813", .board_type = boardISO813, .n_aichan = 32, - .ai_maxdata = 0x0fff, .rangelist_ai = &range_iso813_1_ai, }, { .name = "acl8216", .board_type = boardACL8216, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0xffff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_16bit_ai = 1, .has_mpc508_mux = 1, .has_dio = 1, }, { @@ -513,11 +497,11 @@ static const struct pcl812_board boardtypes[] = { .board_type = boardACL8216, .n_aichan = 16, /* 8 differential */ .n_aochan = 2, - .ai_maxdata = 0xffff, .ai_ns_min = 10000, .rangelist_ai = &range_pcl813b2_ai, .IRQbits = 0xdcfc, .has_dma = 1, + .has_16bit_ai = 1, .has_dio = 1, }, }; @@ -1446,7 +1430,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags |= SDF_GROUND; s->n_chan = board->n_aichan; } - s->maxdata = board->ai_maxdata; + s->maxdata = board->has_16bit_ai ? 0xffff : 0x0fff; pcl812_set_ai_range_table(dev, s, it); From 4bae1f4bd195589bb1c97966e0965946363ddc4b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:14 -0700 Subject: [PATCH 0341/1375] staging: comedi: pcl812: introduce pcl812_ai_get_sample() Introduce a helper function to read the 12/16-bit analog input data sample. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 4ecbb297dcb7..d7b125d4b16b 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -551,6 +551,17 @@ static void setup_range_channel(struct comedi_device *dev, static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static unsigned int pcl812_ai_get_sample(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned int val; + + val = inb(dev->iobase + PCL812_AD_HI) << 8; + val |= inb(dev->iobase + PCL812_AD_LO); + + return val & s->maxdata; +} + static int pcl812_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -578,7 +589,6 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, struct pcl812_private *devpriv = dev->private; int ret = 0; int n; - int hi; /* select software trigger */ outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE); @@ -593,8 +603,7 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, if (ret) break; - hi = inb(dev->iobase + PCL812_AD_HI); - data[n] = ((hi & 0xf) << 8) | inb(dev->iobase + PCL812_AD_LO); + data[n] = pcl812_ai_get_sample(dev, s); } outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); @@ -621,9 +630,7 @@ static int acl8216_ai_insn_read(struct comedi_device *dev, if (ret) break; - data[n] = - (inb(dev->iobase + - PCL812_AD_HI) << 8) | inb(dev->iobase + PCL812_AD_LO); + data[n] = pcl812_ai_get_sample(dev, s); } outb(0, dev->iobase + PCL812_MODE); @@ -912,7 +919,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) { char err = 1; - unsigned int mask, timeout; + unsigned int timeout; struct comedi_device *dev = d; struct pcl812_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; @@ -922,7 +929,6 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) timeout = 50; /* wait max 50us, it must finish under 33us */ if (devpriv->ai_is16b) { - mask = 0xffff; while (timeout--) { if (!(inb(dev->iobase + ACL8216_STATUS) & ACL8216_DRDY)) { err = 0; @@ -931,7 +937,6 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) udelay(1); } } else { - mask = 0x0fff; while (timeout--) { if (!(inb(dev->iobase + PCL812_AD_HI) & PCL812_DRDY)) { err = 0; @@ -949,9 +954,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) return IRQ_HANDLED; } - comedi_buf_put(s->async, - ((inb(dev->iobase + PCL812_AD_HI) << 8) | - inb(dev->iobase + PCL812_AD_LO)) & mask); + comedi_buf_put(s->async, pcl812_ai_get_sample(dev, s)); /* Set up next channel. Added by abbotti 2010-01-20, but untested. */ next_chan = s->async->cur_chan + 1; From 66581ca576717229d65003f0870d6dd14e1fe52e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:15 -0700 Subject: [PATCH 0342/1375] staging: comedi: pcl816: introduce pcl816_ai_get_sample() Introduce a helper function to read the 14/16-bit analog input data sample. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 7e7c30247eef..6d3965bffdaf 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -165,6 +165,17 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd); static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static unsigned int pcl816_ai_get_sample(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned int val; + + val = inb(dev->iobase + PCL816_AD_HI) << 8; + val |= inb(dev->iobase + PCL816_AD_LO); + + return val & s->maxdata; +} + static int pcl816_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -206,9 +217,8 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, return ret; } - /* return read value */ - data[n] = ((inb(dev->iobase + PCL816_AD_HI) << 8) | - (inb(dev->iobase + PCL816_AD_LO))); + data[n] = pcl816_ai_get_sample(dev, s); + /* clear INT (conversion end) flag */ outb(0, dev->iobase + PCL816_CLRINT); } @@ -225,7 +235,6 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) struct comedi_device *dev = d; struct pcl816_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - unsigned char low, hi; int timeout = 50; /* wait max 50us */ while (timeout--) { @@ -244,11 +253,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) } - /* get the sample */ - low = inb(dev->iobase + PCL816_AD_LO); - hi = inb(dev->iobase + PCL816_AD_HI); - - comedi_buf_put(s->async, (hi << 8) | low); + comedi_buf_put(s->async, pcl816_ai_get_sample(dev, s)); outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ @@ -655,8 +660,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, outb(0xb0, dev->iobase + PCL816_CTRCTL); outb(0x70, dev->iobase + PCL816_CTRCTL); outb(0, dev->iobase + PCL816_AD_LO); - inb(dev->iobase + PCL816_AD_LO); - inb(dev->iobase + PCL816_AD_HI); + pcl816_ai_get_sample(dev, s); /* clear INT request */ outb(0, dev->iobase + PCL816_CLRINT); From 8fc9f652abd71fd53e17c3b2430e702e5a55fae2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:16 -0700 Subject: [PATCH 0343/1375] staging: comedi: pcl818: introduce pcl818_ai_get_sample() Introduce a helper function to read the 12-bit analog input data sample and optionally return the channel that the sample was for. The channel is only used in the interrupt routine to check for dropped samples. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 30 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 2b8e7e0d2c75..d5709edd6799 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -372,6 +372,21 @@ static int pcl818_ai_cancel(struct comedi_device *dev, static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2); +static unsigned int pcl818_ai_get_sample(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int *chan) +{ + unsigned int val; + + val = inb(dev->iobase + PCL818_AD_HI) << 8; + val |= inb(dev->iobase + PCL818_AD_LO); + + if (chan) + *chan = val & 0xf; + + return (val >> 4) & s->maxdata; +} + static int pcl818_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -416,8 +431,7 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, return ret; } - data[n] = ((inb(dev->iobase + PCL818_AD_HI) << 4) | - (inb(dev->iobase + PCL818_AD_LO) >> 4)); + data[n] = pcl818_ai_get_sample(dev, s, NULL); } return n; @@ -502,7 +516,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) struct comedi_device *dev = d; struct pcl818_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - unsigned char low; + unsigned int chan; int timeout = 50; /* wait max 50us */ while (timeout--) { @@ -518,14 +532,13 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) return IRQ_HANDLED; conv_finish: - low = inb(dev->iobase + PCL818_AD_LO); - comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); /* get one sample */ + comedi_buf_put(s->async, pcl818_ai_get_sample(dev, s, &chan)); outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ - if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */ + if (chan != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { dev_dbg(dev->class_dev, "A/D mode1/3 IRQ - channel dropout %x!=%x !\n", - (low & 0xf), + chan, devpriv->act_chanlist[devpriv->act_chanlist_pos]); pcl818_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; @@ -1166,8 +1179,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, udelay(1); start_pacer(dev, -1, 0, 0); outb(0, dev->iobase + PCL818_AD_LO); - inb(dev->iobase + PCL818_AD_LO); - inb(dev->iobase + PCL818_AD_HI); + pcl818_ai_get_sample(dev, s, NULL); outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ outb(0, dev->iobase + PCL818_CONTROL); /* Stop A/D */ if (devpriv->usefifo) { /* FIFO shutdown */ From 4af1eb3e5d77f59a57582cba8d1a4415310fbacd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:17 -0700 Subject: [PATCH 0344/1375] staging: comedi: pcl812: remove 'ai_is16b' from private data We can check the subdevice 'maxdata' to determine if the analog input data is 12 or 16-bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index d7b125d4b16b..c61ec5f01a6d 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -527,7 +527,6 @@ struct pcl812_private { unsigned int ai_n_chan; /* how many channels is measured */ unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ - unsigned int ai_is16b; /* =1 we have 16 bit card */ unsigned long dmabuf[2]; /* PTR to DMA buf */ unsigned int dmapages[2]; /* how many pages we have allocated */ unsigned int hwdmaptr[2]; /* HW PTR to DMA buf */ @@ -567,10 +566,9 @@ static int pcl812_ai_eoc(struct comedi_device *dev, struct comedi_insn *insn, unsigned long context) { - struct pcl812_private *devpriv = dev->private; unsigned int status; - if (devpriv->ai_is16b) { + if (s->maxdata > 0x0fff) { status = inb(dev->iobase + ACL8216_STATUS); if ((status & ACL8216_DRDY) == 0) return 0; @@ -928,7 +926,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) s->async->events = 0; timeout = 50; /* wait max 50us, it must finish under 33us */ - if (devpriv->ai_is16b) { + if (s->maxdata > 0x0fff) { while (timeout--) { if (!(inb(dev->iobase + ACL8216_STATUS) & ACL8216_DRDY)) { err = 0; @@ -1508,7 +1506,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) switch (board->board_type) { case boardACL8216: - devpriv->ai_is16b = 1; case boardPCL812PG: case boardPCL812: case boardACL8112: From afa876b94baeefe44b645a3f379ff514475f9058 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:18 -0700 Subject: [PATCH 0345/1375] staging: comedi: pcl812: remove acl8216_ai_insn_read() This (*insn_read) function was used to read 16-bit analog input data from the boardACL8216 boardtypes. The 12/16-bit differences are now handled by the pcl812_ai_eoc() and pcl812_ai_get_sample() helpers. Remove this function and use pcl812_ai_insn_read() for all boardtypes. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 32 +------------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index c61ec5f01a6d..522a58772ed8 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -608,33 +608,6 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, return ret ? ret : n; } -static int acl8216_ai_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - int ret = 0; - int n; - - /* select software trigger */ - outb(1, dev->iobase + PCL812_MODE); - /* select channel and renge */ - setup_range_channel(dev, s, insn->chanspec, 1); - for (n = 0; n < insn->n; n++) { - /* start conversion */ - outb(255, dev->iobase + PCL812_SOFTTRIG); - udelay(5); - - ret = comedi_timeout(dev, s, insn, pcl812_ai_eoc, 0); - if (ret) - break; - - data[n] = pcl812_ai_get_sample(dev, s); - } - outb(0, dev->iobase + PCL812_MODE); - - return ret ? ret : n; -} - /* ============================================================================== */ @@ -1435,10 +1408,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) pcl812_set_ai_range_table(dev, s, it); - if (board->board_type == boardACL8216) - s->insn_read = acl8216_ai_insn_read; - else - s->insn_read = pcl812_ai_insn_read; + s->insn_read = pcl812_ai_insn_read; if (dev->irq) { dev->read_subdev = s; From 0d0c6323fa4ec7ac8f413f8a60f9bba215ce51ca Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:19 -0700 Subject: [PATCH 0346/1375] staging: comedi: pcl812: remove 'valid' from private data This member of the private data is set but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 522a58772ed8..ec6d37d4937e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -507,8 +507,6 @@ static const struct pcl812_board boardtypes[] = { }; struct pcl812_private { - - unsigned char valid; /* =1 device is OK */ unsigned char dma; /* >0 use dma ( usedDMA channel) */ unsigned char use_diff; /* =1 diff inputs */ unsigned char use_MPC; /* 1=board uses MPC508A multiplexor */ @@ -1497,8 +1495,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) break; } - devpriv->valid = 1; - pcl812_reset(dev); return 0; From c3150ae72058bf62cfd7021456883e2ddf815387 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:20 -0700 Subject: [PATCH 0347/1375] staging: comedi: pcl812: remove 'ai_scans' from private data This member of the private data is just a copy of the cmd->stop_arg. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index ec6d37d4937e..9dcd9684c048 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -519,7 +519,6 @@ struct pcl812_private { unsigned char ai_eos; /* 1=EOS wake up */ unsigned char ai_dma; /* =1 we use DMA */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ - unsigned int ai_scans; /* len of scanlist */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */ unsigned int ai_n_chan; /* how many channels is measured */ @@ -792,13 +791,10 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ai_scans = cmd->stop_arg; + if (cmd->stop_src == TRIG_COUNT) devpriv->ai_neverending = 0; - } else { - devpriv->ai_scans = 0; + else devpriv->ai_neverending = 1; - } devpriv->ai_act_scan = 0; devpriv->ai_poll_ptr = 0; @@ -835,7 +831,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } else { /* how many samples we must transfer? */ bytes = devpriv->ai_n_chan * - devpriv->ai_scans * sizeof(short); + cmd->stop_arg * sizeof(short); /* how many DMA pages we must fill */ devpriv->dma_runs_to_end = @@ -892,6 +888,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) struct comedi_device *dev = d; struct pcl812_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int next_chan; s->async->events = 0; @@ -940,7 +937,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) devpriv->ai_act_scan++; if (!(devpriv->ai_neverending)) /* all data sampled */ - if (devpriv->ai_act_scan >= devpriv->ai_scans) { + if (devpriv->ai_act_scan >= cmd->stop_arg) { pcl812_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } @@ -959,6 +956,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, unsigned int bufptr, unsigned int len) { struct pcl812_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int i; s->async->events = 0; @@ -972,7 +970,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, devpriv->ai_act_scan++; if (!devpriv->ai_neverending) /* all data sampled */ - if (devpriv->ai_act_scan >= devpriv->ai_scans) { + if (devpriv->ai_act_scan >= cmd->stop_arg) { pcl812_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; break; From 6e15fcb24011c0ebca7359cc4ee7d1bf0a229b3a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:21 -0700 Subject: [PATCH 0348/1375] staging: comedi: pcl816: remove 'ai_scans' from private data This member of the private data is just a copy of the cmd->stop_arg. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 6d3965bffdaf..042b4c372bfb 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -131,8 +131,6 @@ struct pcl816_private { int next_dma_buf; /* which DMA buffer will be used next round */ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ - - unsigned int ai_scans; /* len of scanlist */ unsigned char ai_neverending; /* if=1, then we do neverending record (you must use cancel()) */ int irq_blocked; /* 1=IRQ now uses any subdev */ int irq_was_now_closed; /* when IRQ finish, there's stored int816_mode for last interrupt */ @@ -235,6 +233,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) struct comedi_device *dev = d; struct pcl816_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; int timeout = 50; /* wait max 50us */ while (timeout--) { @@ -268,7 +267,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) if (!devpriv->ai_neverending) /* all data sampled */ - if (devpriv->ai_act_scan >= devpriv->ai_scans) { + if (devpriv->ai_act_scan >= cmd->stop_arg) { /* all data sampled */ pcl816_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; @@ -287,6 +286,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, unsigned int bufptr, unsigned int len) { struct pcl816_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int i; s->async->events = 0; @@ -308,7 +308,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, if (!devpriv->ai_neverending) /* all data sampled */ - if (devpriv->ai_act_scan >= devpriv->ai_scans) { + if (devpriv->ai_act_scan >= cmd->stop_arg) { pcl816_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_BLOCK; @@ -527,13 +527,10 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_poll_ptr = 0; devpriv->irq_was_now_closed = 0; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ai_scans = cmd->stop_arg; + if (cmd->stop_src == TRIG_COUNT) devpriv->ai_neverending = 0; - } else { - devpriv->ai_scans = 0; + else devpriv->ai_neverending = 1; - } if (devpriv->dma) { bytes = devpriv->hwdmasize[0]; From c2e519dd212937d3726ef9e326b35185295c455a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:22 -0700 Subject: [PATCH 0349/1375] staging: comedi: pcl818: remove 'ai_scans' from private data This member of the private data is just a copy of the cmd->stop_arg. Refactor the code to follow the style of pcl812 and pcl816 drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index d5709edd6799..eea48ded0413 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -341,7 +341,6 @@ struct pcl818_private { unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */ unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ - unsigned int ai_scans; /* len of scanlist */ unsigned int ai_n_chan; /* how many channels is measured */ unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_flags; /* flaglist */ @@ -790,13 +789,14 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev, struct comedi_subdevice *s) { struct pcl818_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int flags; unsigned int bytes; disable_dma(devpriv->dma); /* disable dma */ bytes = devpriv->hwdmasize[0]; if (!devpriv->neverending_ai) { - bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many */ + bytes = devpriv->ai_n_chan * cmd->stop_arg * sizeof(short); /* how many */ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fiil */ devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */ devpriv->dma_runs_to_end--; @@ -848,17 +848,13 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, udelay(1); - devpriv->ai_act_scan = devpriv->ai_scans; + devpriv->ai_act_scan = cmd->stop_arg; devpriv->ai_act_chan = 0; devpriv->irq_blocked = 1; devpriv->irq_was_now_closed = 0; - devpriv->neverending_ai = 0; devpriv->act_chanlist_pos = 0; devpriv->dma_runs_to_end = 0; - if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) - devpriv->neverending_ai = 1; /* well, user want neverending */ - if (mode == 1) { i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1, &divisor2, @@ -1127,9 +1123,9 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_timer2 = 0; if (cmd->stop_src == TRIG_COUNT) - devpriv->ai_scans = cmd->stop_arg; + devpriv->neverending_ai = 0; else - devpriv->ai_scans = 0; + devpriv->neverending_ai = 1; if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 3 */ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */ From dbdd7737e8f5401dad89e71256396bdb9df7266a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:23 -0700 Subject: [PATCH 0350/1375] staging: comedi: pcl812: remove 'ai_n_chan' from private data This member of the private data is just a copy of the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 9dcd9684c048..4d9cc391b0a7 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -521,7 +521,6 @@ struct pcl812_private { unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */ - unsigned int ai_n_chan; /* how many channels is measured */ unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ unsigned long dmabuf[2]; /* PTR to DMA buf */ @@ -772,7 +771,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) start_pacer(dev, -1, 0, 0); /* stop pacer */ - devpriv->ai_n_chan = cmd->chanlist_len; memcpy(devpriv->ai_chanlist, cmd->chanlist, sizeof(unsigned int) * cmd->scan_end_arg); /* select first channel and range */ @@ -780,7 +778,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->dma) { /* check if we can use DMA transfer */ devpriv->ai_dma = 1; - for (i = 1; i < devpriv->ai_n_chan; i++) + for (i = 1; i < cmd->chanlist_len; i++) if (devpriv->ai_chanlist[0] != devpriv->ai_chanlist[i]) { /* we cann't use DMA :-( */ devpriv->ai_dma = 0; @@ -805,7 +803,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_eos = 1; /* DMA is useless for this situation */ - if (devpriv->ai_n_chan == 1) + if (cmd->chanlist_len == 1) devpriv->ai_dma = 0; } @@ -813,9 +811,9 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* we use EOS, so adapt DMA buffer to one scan */ if (devpriv->ai_eos) { devpriv->dmabytestomove[0] = - devpriv->ai_n_chan * sizeof(short); + cmd->chanlist_len * sizeof(short); devpriv->dmabytestomove[1] = - devpriv->ai_n_chan * sizeof(short); + cmd->chanlist_len * sizeof(short); devpriv->dma_runs_to_end = 1; } else { devpriv->dmabytestomove[0] = devpriv->hwdmasize[0]; @@ -830,7 +828,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->dma_runs_to_end = 1; } else { /* how many samples we must transfer? */ - bytes = devpriv->ai_n_chan * + bytes = cmd->chanlist_len * cmd->stop_arg * sizeof(short); /* how many DMA pages we must fill */ @@ -924,7 +922,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) /* Set up next channel. Added by abbotti 2010-01-20, but untested. */ next_chan = s->async->cur_chan + 1; - if (next_chan >= devpriv->ai_n_chan) + if (next_chan >= cmd->chanlist_len) next_chan = 0; if (devpriv->ai_chanlist[s->async->cur_chan] != devpriv->ai_chanlist[next_chan]) @@ -965,7 +963,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, comedi_buf_put(s->async, ptr[bufptr++]); s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; devpriv->ai_act_scan++; if (!devpriv->ai_neverending) From 91471f9b45d5c36aa50c0940dfaf64fb13cf4fe5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:24 -0700 Subject: [PATCH 0351/1375] staging: comedi: pcl816: remove 'ai_n_chan' from private data This member of the private data is just a copy of the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 042b4c372bfb..77bf99698144 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -140,7 +140,6 @@ struct pcl816_private { unsigned int ai_act_chanlist[16]; /* MUX setting for actual AI operations */ unsigned int ai_act_chanlist_len; /* how long is actual MUX list */ unsigned int ai_act_chanlist_pos; /* actual position in MUX list */ - unsigned int ai_n_chan; /* how many channels per scan */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ }; @@ -260,7 +259,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) devpriv->ai_act_chanlist_pos = 0; s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; devpriv->ai_act_scan++; } @@ -301,7 +300,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, } s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; devpriv->ai_act_scan++; } @@ -520,7 +519,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) setup_channel_list(dev, s, cmd->chanlist, seglen); udelay(1); - devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_act_scan = 0; s->async->cur_chan = 0; devpriv->irq_blocked = 1; From 41bbe835f1cd48a14af2cd3a3a9b41e1528f07dc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:25 -0700 Subject: [PATCH 0352/1375] staging: comedi: pcl818: remove 'ai_n_chan' from private data This member of the private data is just a copy of the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index eea48ded0413..f73fc791a13c 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -341,7 +341,6 @@ struct pcl818_private { unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */ unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ - unsigned int ai_n_chan; /* how many channels is measured */ unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ @@ -515,6 +514,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) struct comedi_device *dev = d; struct pcl818_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int chan; int timeout = 50; /* wait max 50us */ @@ -549,7 +549,7 @@ conv_finish: devpriv->act_chanlist_pos = 0; s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; devpriv->ai_act_scan--; } @@ -573,6 +573,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) struct comedi_device *dev = d; struct pcl818_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; int i, len, bufptr; unsigned long flags; unsigned short *ptr; @@ -622,7 +623,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) devpriv->act_chanlist_pos = 0; s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; devpriv->ai_act_scan--; } @@ -650,6 +651,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) struct comedi_device *dev = d; struct pcl818_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; int i, len; unsigned char lo; @@ -698,7 +700,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) devpriv->act_chanlist_pos = 0; s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; devpriv->ai_act_scan--; } @@ -796,7 +798,7 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev, disable_dma(devpriv->dma); /* disable dma */ bytes = devpriv->hwdmasize[0]; if (!devpriv->neverending_ai) { - bytes = devpriv->ai_n_chan * cmd->stop_arg * sizeof(short); /* how many */ + bytes = cmd->chanlist_len * cmd->stop_arg * sizeof(short); /* how many */ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fiil */ devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */ devpriv->dma_runs_to_end--; @@ -840,11 +842,11 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, start_pacer(dev, -1, 0, 0); /* stop pacer */ seglen = check_channel_list(dev, s, devpriv->ai_chanlist, - devpriv->ai_n_chan); + cmd->chanlist_len); if (seglen < 1) return -EINVAL; setup_channel_list(dev, s, devpriv->ai_chanlist, - devpriv->ai_n_chan, seglen); + cmd->chanlist_len, seglen); udelay(1); @@ -1115,7 +1117,6 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; int retval; - devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; From 7c2686b5a58ec8bd397480305963000f2e3ba5e3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:26 -0700 Subject: [PATCH 0353/1375] staging: comedi: pcl812: remove 'ai_flags' from private data This member of the private data is just a copy of the cmd->flags. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 4d9cc391b0a7..b2a5a43047e6 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -521,7 +521,6 @@ struct pcl812_private { unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */ - unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ unsigned long dmabuf[2]; /* PTR to DMA buf */ unsigned int dmapages[2]; /* how many pages we have allocated */ @@ -787,7 +786,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } else devpriv->ai_dma = 0; - devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; if (cmd->stop_src == TRIG_COUNT) devpriv->ai_neverending = 0; @@ -799,7 +797,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) s->async->cur_chan = 0; /* don't we want wake up every scan? */ - if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { + if (cmd->flags & TRIG_WAKE_EOS) { devpriv->ai_eos = 1; /* DMA is useless for this situation */ From 0f536336e4530748f3fd8e76e0b4899faec3da09 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:27 -0700 Subject: [PATCH 0354/1375] staging: comedi: pcl818: remove 'ai_flags' from private data This member of the private data is not used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index f73fc791a13c..dcc397cf45bb 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -342,7 +342,6 @@ struct pcl818_private { unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ unsigned int *ai_chanlist; /* actaul chanlist */ - unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ unsigned int ai_timer1; /* timers */ unsigned int ai_timer2; @@ -1118,7 +1117,6 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int retval; devpriv->ai_chanlist = cmd->chanlist; - devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; devpriv->ai_timer1 = 0; devpriv->ai_timer2 = 0; From 00ebe61736b56336bf6a48394602b0846637e6df Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:28 -0700 Subject: [PATCH 0355/1375] staging: comedi: pcl812: tidy up dma buffer allocation This driver uses 2 buffers for DMA. Refactor the buffer allocation to use a for loop to remove code duplication. Remove the dev_err() messages when __get_dma_pages() fails and change the errno returned from -EBUSY to -ENOMEM. Both buffers are the same size so replace the 'dmapages' and 'hwdmasize' arrays in the private data with variables to save a bit of space. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 63 +++++++++++-------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index b2a5a43047e6..9ff15b0dd096 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -522,10 +522,10 @@ struct pcl812_private { unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */ unsigned int ai_data_len; /* len of data buffer */ + unsigned int dmapages; + unsigned int hwdmasize; unsigned long dmabuf[2]; /* PTR to DMA buf */ - unsigned int dmapages[2]; /* how many pages we have allocated */ unsigned int hwdmaptr[2]; /* HW PTR to DMA buf */ - unsigned int hwdmasize[2]; /* DMA buf size in bytes */ unsigned int dmabytestomove[2]; /* how many bytes DMA transfer */ int next_dma_buf; /* which buffer is next to use */ unsigned int dma_runs_to_end; /* how many times we must switch DMA buffers */ @@ -814,14 +814,14 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) cmd->chanlist_len * sizeof(short); devpriv->dma_runs_to_end = 1; } else { - devpriv->dmabytestomove[0] = devpriv->hwdmasize[0]; - devpriv->dmabytestomove[1] = devpriv->hwdmasize[1]; - if (devpriv->ai_data_len < devpriv->hwdmasize[0]) + devpriv->dmabytestomove[0] = devpriv->hwdmasize; + devpriv->dmabytestomove[1] = devpriv->hwdmasize; + if (devpriv->ai_data_len < devpriv->hwdmasize) { devpriv->dmabytestomove[0] = devpriv->ai_data_len; - if (devpriv->ai_data_len < devpriv->hwdmasize[1]) devpriv->dmabytestomove[1] = devpriv->ai_data_len; + } if (devpriv->ai_neverending) { devpriv->dma_runs_to_end = 1; } else { @@ -842,12 +842,12 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->dma_runs_to_end--; } } - if (devpriv->dmabytestomove[0] > devpriv->hwdmasize[0]) { - devpriv->dmabytestomove[0] = devpriv->hwdmasize[0]; + if (devpriv->dmabytestomove[0] > devpriv->hwdmasize) { + devpriv->dmabytestomove[0] = devpriv->hwdmasize; devpriv->ai_eos = 0; } - if (devpriv->dmabytestomove[1] > devpriv->hwdmasize[1]) { - devpriv->dmabytestomove[1] = devpriv->hwdmasize[1]; + if (devpriv->dmabytestomove[1] > devpriv->hwdmasize) { + devpriv->dmabytestomove[1] = devpriv->hwdmasize; devpriv->ai_eos = 0; } devpriv->next_dma_buf = 0; @@ -1303,10 +1303,11 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl812_board *board = comedi_board(dev); struct pcl812_private *devpriv; - int ret, subdev; - unsigned long pages; struct comedi_subdevice *s; int n_subdevices; + int subdev; + int ret; + int i; ret = comedi_request_region(dev, it->options[0], 0x10); if (ret) @@ -1335,29 +1336,19 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) } devpriv->dma = it->options[2]; - pages = 1; /* we want 8KB */ - devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); - if (!devpriv->dmabuf[0]) { - dev_err(dev->class_dev, - "unable to allocate DMA buffer, FAIL!\n"); - /* - * maybe experiment with try_to_free_pages() - * will help .... - */ - return -EBUSY; /* no buffer :-( */ + devpriv->dmapages = 1; /* we want 8KB */ + devpriv->hwdmasize = (1 << devpriv->dmapages) * PAGE_SIZE; + + for (i = 0; i < 2; i++) { + unsigned long dmabuf; + + dmabuf = __get_dma_pages(GFP_KERNEL, devpriv->dmapages); + if (!dmabuf) + return -ENOMEM; + + devpriv->dmabuf[i] = dmabuf; + devpriv->hwdmaptr[i] = virt_to_bus((void *)dmabuf); } - devpriv->dmapages[0] = pages; - devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]); - devpriv->hwdmasize[0] = PAGE_SIZE * (1 << pages); - devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); - if (!devpriv->dmabuf[1]) { - dev_err(dev->class_dev, - "unable to allocate DMA buffer, FAIL!\n"); - return -EBUSY; - } - devpriv->dmapages[1] = pages; - devpriv->hwdmaptr[1] = virt_to_bus((void *)devpriv->dmabuf[1]); - devpriv->hwdmasize[1] = PAGE_SIZE * (1 << pages); } /* differential analog inputs? */ @@ -1500,9 +1491,9 @@ static void pcl812_detach(struct comedi_device *dev) if (devpriv) { if (devpriv->dmabuf[0]) - free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]); + free_pages(devpriv->dmabuf[0], devpriv->dmapages); if (devpriv->dmabuf[1]) - free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]); + free_pages(devpriv->dmabuf[1], devpriv->dmapages); if (devpriv->dma) free_dma(devpriv->dma); } From 55b95f14304a7daa8f5253e4054a951e036c735d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:29 -0700 Subject: [PATCH 0356/1375] staging: comedi: pcl816: tidy up dma buffer allocation This driver uses 2 buffers for DMA. Refactor the buffer allocation to use a for loop to remove code duplication. Remove the dev_err() messages when __get_dma_pages() fails and change the errno returned from -EBUSY to -ENOMEM. Both buffers are the same size so replace the 'dmapages' and 'hwdmasize' arrays in the private data with variables to save a bit of space. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 68 +++++++++---------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 77bf99698144..29d462513c62 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -121,12 +121,11 @@ static const struct pcl816_board boardtypes[] = { }; struct pcl816_private { - unsigned int dma; /* used DMA, 0=don't use DMA */ + unsigned int dmapages; + unsigned int hwdmasize; unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */ - unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */ unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */ - unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */ unsigned int dmasamplsize; /* size in samples hwdmasize[0]/2 */ int next_dma_buf; /* which DMA buffer will be used next round */ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ @@ -339,13 +338,10 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d) /* clear_dma_ff (devpriv->dma); */ set_dma_addr(devpriv->dma, devpriv->hwdmaptr[devpriv->next_dma_buf]); - if (devpriv->dma_runs_to_end) { - set_dma_count(devpriv->dma, - devpriv->hwdmasize[devpriv-> - next_dma_buf]); - } else { + if (devpriv->dma_runs_to_end) + set_dma_count(devpriv->dma, devpriv->hwdmasize); + else set_dma_count(devpriv->dma, devpriv->last_dma_run); - } release_dma_lock(dma_flags); enable_dma(devpriv->dma); } @@ -355,7 +351,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d) ptr = (unsigned short *)devpriv->dmabuf[this_dma_buf]; - len = (devpriv->hwdmasize[0] >> 1) - devpriv->ai_poll_ptr; + len = (devpriv->hwdmasize >> 1) - devpriv->ai_poll_ptr; bufptr = devpriv->ai_poll_ptr; devpriv->ai_poll_ptr = 0; @@ -531,7 +527,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_neverending = 1; if (devpriv->dma) { - bytes = devpriv->hwdmasize[0]; + bytes = devpriv->hwdmasize; if (!devpriv->ai_neverending) { /* how many */ bytes = s->async->cmd.chanlist_len * @@ -539,14 +535,13 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) sizeof(short); /* how many DMA pages we must fill */ - devpriv->dma_runs_to_end = bytes / - devpriv->hwdmasize[0]; + devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; /* on last dma transfer must be moved */ - devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; + devpriv->last_dma_run = bytes % devpriv->hwdmasize; devpriv->dma_runs_to_end--; if (devpriv->dma_runs_to_end >= 0) - bytes = devpriv->hwdmasize[0]; + bytes = devpriv->hwdmasize; } else devpriv->dma_runs_to_end = -1; @@ -611,7 +606,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) } /* where is now DMA in buffer */ - top1 = devpriv->hwdmasize[0] - top1; + top1 = devpriv->hwdmasize - top1; top1 >>= 1; /* sample position */ top2 = top1 - devpriv->ai_poll_ptr; if (top2 < 1) { /* no new samples */ @@ -843,10 +838,9 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl816_board *board = comedi_board(dev); struct pcl816_private *devpriv; - int ret; - unsigned long pages; - /* int i; */ struct comedi_subdevice *s; + int ret; + int i; ret = comedi_request_region(dev, it->options[0], 0x10); if (ret) @@ -882,31 +876,19 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) } devpriv->dma = it->options[2]; - pages = 2; /* we need 16KB */ - devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); + devpriv->dmapages = 2; /* we need 16KB */ + devpriv->hwdmasize = (1 << devpriv->dmapages) * PAGE_SIZE; - if (!devpriv->dmabuf[0]) { - dev_err(dev->class_dev, - "unable to allocate DMA buffer, FAIL!\n"); - /* - * maybe experiment with try_to_free_pages() - * will help .... - */ - return -EBUSY; /* no buffer :-( */ - } - devpriv->dmapages[0] = pages; - devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]); - devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE; + for (i = 0; i < 2; i++) { + unsigned long dmabuf; - devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); - if (!devpriv->dmabuf[1]) { - dev_err(dev->class_dev, - "unable to allocate DMA buffer, FAIL!\n"); - return -EBUSY; + dmabuf = __get_dma_pages(GFP_KERNEL, devpriv->dmapages); + if (!dmabuf) + return -ENOMEM; + + devpriv->dmabuf[i] = dmabuf; + devpriv->hwdmaptr[i] = virt_to_bus((void *)dmabuf); } - devpriv->dmapages[1] = pages; - devpriv->hwdmaptr[1] = virt_to_bus((void *)devpriv->dmabuf[1]); - devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE; } ret = comedi_alloc_subdevices(dev, 1); @@ -968,9 +950,9 @@ static void pcl816_detach(struct comedi_device *dev) if (devpriv->dma) free_dma(devpriv->dma); if (devpriv->dmabuf[0]) - free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]); + free_pages(devpriv->dmabuf[0], devpriv->dmapages); if (devpriv->dmabuf[1]) - free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]); + free_pages(devpriv->dmabuf[1], devpriv->dmapages); } comedi_legacy_detach(dev); } From f5cc425afed63820734f130fc245ba7bb11c11ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:30 -0700 Subject: [PATCH 0357/1375] staging: comedi: pcl818: tidy up dma buffer allocation This driver uses 2 buffers for DMA. Refactor the buffer allocation to use a for loop to remove code duplication. Remove the dev_err() messages when __get_dma_pages() fails and change the errno returned from -EBUSY to -ENOMEM. Both buffers are the same size so replace the 'dmapages' and 'hwdmasize' arrays in the private data with variables to save a bit of space. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 61 ++++++++++++------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index dcc397cf45bb..e2629087d097 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -320,12 +320,11 @@ static const struct pcl818_board boardtypes[] = { }; struct pcl818_private { - unsigned int dma; /* used DMA, 0=don't use DMA */ + unsigned int dmapages; + unsigned int hwdmasize; unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */ - unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */ unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */ - unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */ int next_dma_buf; /* which DMA buffer will be used next round */ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ @@ -584,13 +583,10 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) flags = claim_dma_lock(); set_dma_addr(devpriv->dma, devpriv->hwdmaptr[devpriv->next_dma_buf]); - if (devpriv->dma_runs_to_end || devpriv->neverending_ai) { - set_dma_count(devpriv->dma, - devpriv->hwdmasize[devpriv-> - next_dma_buf]); - } else { + if (devpriv->dma_runs_to_end || devpriv->neverending_ai) + set_dma_count(devpriv->dma, devpriv->hwdmasize); + else set_dma_count(devpriv->dma, devpriv->last_dma_run); - } release_dma_lock(flags); enable_dma(devpriv->dma); } @@ -599,7 +595,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ ptr = (unsigned short *)devpriv->dmabuf[1 - devpriv->next_dma_buf]; - len = devpriv->hwdmasize[0] >> 1; + len = devpriv->hwdmasize >> 1; bufptr = 0; for (i = 0; i < len; i++) { @@ -795,14 +791,14 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev, unsigned int bytes; disable_dma(devpriv->dma); /* disable dma */ - bytes = devpriv->hwdmasize[0]; + bytes = devpriv->hwdmasize; if (!devpriv->neverending_ai) { - bytes = cmd->chanlist_len * cmd->stop_arg * sizeof(short); /* how many */ - devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fiil */ - devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */ + bytes = cmd->chanlist_len * cmd->stop_arg * sizeof(short); + devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; + devpriv->last_dma_run = bytes % devpriv->hwdmasize; devpriv->dma_runs_to_end--; if (devpriv->dma_runs_to_end >= 0) - bytes = devpriv->hwdmasize[0]; + bytes = devpriv->hwdmasize; } devpriv->next_dma_buf = 0; @@ -1308,9 +1304,9 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl818_board *board = comedi_board(dev); struct pcl818_private *devpriv; - int ret; - unsigned long pages; struct comedi_subdevice *s; + int ret; + int i; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) @@ -1353,20 +1349,19 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) } devpriv->dma = it->options[2]; - pages = 2; /* we need 16KB */ - devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); - if (!devpriv->dmabuf[0]) - /* maybe experiment with try_to_free_pages() will help .... */ - return -EBUSY; /* no buffer :-( */ - devpriv->dmapages[0] = pages; - devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]); - devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE; - devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); - if (!devpriv->dmabuf[1]) - return -EBUSY; - devpriv->dmapages[1] = pages; - devpriv->hwdmaptr[1] = virt_to_bus((void *)devpriv->dmabuf[1]); - devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE; + devpriv->dmapages = 2; /* we need 16KB */ + devpriv->hwdmasize = (1 << devpriv->dmapages) * PAGE_SIZE; + + for (i = 0; i < 2; i++) { + unsigned long dmabuf; + + dmabuf = __get_dma_pages(GFP_KERNEL, devpriv->dmapages); + if (!dmabuf) + return -ENOMEM; + + devpriv->dmabuf[i] = dmabuf; + devpriv->hwdmaptr[i] = virt_to_bus((void *)dmabuf); + } } ret = comedi_alloc_subdevices(dev, 4); @@ -1468,9 +1463,9 @@ static void pcl818_detach(struct comedi_device *dev) if (devpriv->dma) free_dma(devpriv->dma); if (devpriv->dmabuf[0]) - free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]); + free_pages(devpriv->dmabuf[0], devpriv->dmapages); if (devpriv->dmabuf[1]) - free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]); + free_pages(devpriv->dmabuf[1], devpriv->dmapages); } comedi_legacy_detach(dev); } From b14ec4bd3f576be2bb7dd4c69764a422d782e06d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:31 -0700 Subject: [PATCH 0358/1375] staging: comedi: pcl816: remove 'last_int_sub' from private data THis member of the private data is set but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 29d462513c62..64355eae75e8 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -134,7 +134,6 @@ struct pcl816_private { int irq_blocked; /* 1=IRQ now uses any subdev */ int irq_was_now_closed; /* when IRQ finish, there's stored int816_mode for last interrupt */ int int816_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ - struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */ int ai_act_scan; /* how many scans we finished */ unsigned int ai_act_chanlist[16]; /* MUX setting for actual AI operations */ unsigned int ai_act_chanlist_len; /* how long is actual MUX list */ @@ -660,7 +659,6 @@ static int pcl816_ai_cancel(struct comedi_device *dev, devpriv->irq_blocked = 0; devpriv->irq_was_now_closed = devpriv->int816_mode; devpriv->int816_mode = 0; - devpriv->last_int_sub = s; /* s->busy = 0; */ break; } From da7c36a51e072aac6d2a799fe32f3dbbfa8737be Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:32 -0700 Subject: [PATCH 0359/1375] staging: comedi: pcl818: remove 'last_int_sub' from private data THis member of the private data is set but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index e2629087d097..0ac07a90192a 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -334,7 +334,6 @@ struct pcl818_private { int irq_blocked; /* 1=IRQ now uses any subdev */ int irq_was_now_closed; /* when IRQ finish, there's stored int818_mode for last interrupt */ int ai_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ - struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */ int ai_act_scan; /* how many scans we finished */ int ai_act_chan; /* actual position in actual scan */ unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */ @@ -1179,7 +1178,6 @@ static int pcl818_ai_cancel(struct comedi_device *dev, outb(0, dev->iobase + PCL818_FI_ENABLE); } devpriv->irq_blocked = 0; - devpriv->last_int_sub = s; devpriv->neverending_ai = 0; devpriv->ai_mode = 0; devpriv->irq_was_now_closed = 0; From f78b7bc1000cca5d01b31a0d06e6ccb196509cf5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:33 -0700 Subject: [PATCH 0360/1375] staging: comedi: pcl812: use 8253.h helpers Use the helper functions in 8253.h to clarify the timer programming. Move start_pacer() to remove the need for the forward declarations. Rename the function so it has namespace associated with the driver. Change the 'mode' parameter. This parameter is really a flag to the function indicating if the divisors should be loaded into the timers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 51 ++++++++++--------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 9ff15b0dd096..b34814da34a0 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -131,10 +131,7 @@ #define boardACL8216 8 /* and ICP DAS A-826PG */ #define boardA821 9 /* PGH, PGL, PGL/NDA versions */ -#define PCL812_CTR0 0 -#define PCL812_CTR1 1 -#define PCL812_CTR2 2 -#define PCL812_CTRCTL 3 +#define PCL812_TIMER_BASE 0x00 #define PCL812_AD_LO 4 #define PCL812_DA1_LO 4 #define PCL812_AD_HI 5 @@ -534,17 +531,27 @@ struct pcl812_private { unsigned int ao_readback[2]; /* data for AO readback */ }; -/* -============================================================================== -*/ -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2); static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int rangechan, char wait); static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers, + unsigned int divisor1, unsigned int divisor2) +{ + unsigned long timer_base = dev->iobase + PCL812_TIMER_BASE; + + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + udelay(1); + + if (load_timers) { + i8254_write(timer_base, 0, 2, divisor2); + i8254_write(timer_base, 0, 1, divisor1); + } +} + static unsigned int pcl812_ai_get_sample(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -768,7 +775,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) &cmd->convert_arg, cmd->flags); } - start_pacer(dev, -1, 0, 0); /* stop pacer */ + pcl812_start_pacer(dev, false, 0, 0); memcpy(devpriv->ai_chanlist, cmd->chanlist, sizeof(unsigned int) * cmd->scan_end_arg); @@ -862,7 +869,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) switch (cmd->convert_src) { case TRIG_TIMER: - start_pacer(dev, 1, divisor1, divisor2); + pcl812_start_pacer(dev, true, divisor1, divisor2); break; } @@ -1134,24 +1141,6 @@ static void setup_range_channel(struct comedi_device *dev, udelay(devpriv->max_812_ai_mode0_rangewait); } -/* -============================================================================== -*/ -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2) -{ - outb(0xb4, dev->iobase + PCL812_CTRCTL); - outb(0x74, dev->iobase + PCL812_CTRCTL); - udelay(1); - - if (mode == 1) { - outb(divisor2 & 0xff, dev->iobase + PCL812_CTR2); - outb((divisor2 >> 8) & 0xff, dev->iobase + PCL812_CTR2); - outb(divisor1 & 0xff, dev->iobase + PCL812_CTR1); - outb((divisor1 >> 8) & 0xff, dev->iobase + PCL812_CTR1); - } -} - /* ============================================================================== */ @@ -1165,7 +1154,7 @@ static int pcl812_ai_cancel(struct comedi_device *dev, outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ /* Stop A/D */ outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); - start_pacer(dev, -1, 0, 0); /* stop 8254 */ + pcl812_start_pacer(dev, false, 0, 0); outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ return 0; } @@ -1193,7 +1182,7 @@ static void pcl812_reset(struct comedi_device *dev) case boardA821: outb(0, dev->iobase + PCL812_DA1_LO); outb(0, dev->iobase + PCL812_DA1_HI); - start_pacer(dev, -1, 0, 0); /* stop 8254 */ + pcl812_start_pacer(dev, false, 0, 0); outb(0, dev->iobase + PCL812_DO_HI); outb(0, dev->iobase + PCL812_DO_LO); outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); From 15e222c1067fd6bbc2dc09fdab1c5f22ac232823 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:34 -0700 Subject: [PATCH 0361/1375] staging: comedi: pcl816: use 8253.h helpers Use the helper functions in 8253.h to clarify the timer programming. Move start_pacer() to remove the need for the forward declarations. Rename the function so it has namespace associated with the driver. Change the 'mode' parameter. This parameter is really a flag to the function indicating if the divisors should be loaded into the timers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 82 +++++++++++-------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 64355eae75e8..998f7b49c1c7 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -44,12 +44,7 @@ Configuration Options: #include "comedi_fc.h" #include "8253.h" -/* INTEL 8254 counters */ -#define PCL816_CTR0 4 -#define PCL816_CTR1 5 -#define PCL816_CTR2 6 -/* R: counter read-back register W: counter control */ -#define PCL816_CTRCTL 7 +#define PCL816_TIMER_BASE 0x04 /* R: A/D high byte W: A/D range control */ #define PCL816_RANGE 9 @@ -152,14 +147,31 @@ static void setup_channel_list(struct comedi_device *dev, unsigned int *chanlist, unsigned int seglen); static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2); static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters, + unsigned int divisor1, unsigned int divisor2) +{ + unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE; + + i8254_set_mode(timer_base, 0, 0, I8254_MODE1 | I8254_BINARY); + i8254_write(timer_base, 0, 0, 0x00ff); + udelay(1); + + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + udelay(1); + + if (load_counters) { + i8254_write(timer_base, 0, 2, divisor2); + i8254_write(timer_base, 0, 1, divisor1); + } +} + static unsigned int pcl816_ai_get_sample(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -506,7 +518,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } } - start_pacer(dev, -1, 0, 0); /* stop pacer */ + pcl816_start_pacer(dev, false, 0, 0); seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len); if (seglen < 1) @@ -554,7 +566,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) enable_dma(devpriv->dma); } - start_pacer(dev, 1, divisor1, divisor2); + pcl816_start_pacer(dev, true, divisor1, divisor2); dmairq = ((devpriv->dma & 0x3) << 4) | (dev->irq & 0x7); switch (cmd->convert_src) { @@ -646,8 +658,11 @@ static int pcl816_ai_cancel(struct comedi_device *dev, outb(0, dev->iobase + PCL816_CONTROL); /* Stop A/D */ /* Stop pacer */ - outb(0xb0, dev->iobase + PCL816_CTRCTL); - outb(0x70, dev->iobase + PCL816_CTRCTL); + i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0, + 2, I8254_MODE0 | I8254_BINARY); + i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0, + 1, I8254_MODE0 | I8254_BINARY); + outb(0, dev->iobase + PCL816_AD_LO); pcl816_ai_get_sample(dev, s); @@ -695,6 +710,8 @@ static int pcl816_check(unsigned long iobase) */ static void pcl816_reset(struct comedi_device *dev) { + unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE; + /* outb (0, dev->iobase + PCL818_DA_LO); DAC=0V */ /* outb (0, dev->iobase + PCL818_DA_HI); */ /* udelay (1); */ @@ -704,44 +721,15 @@ static void pcl816_reset(struct comedi_device *dev) outb(0, dev->iobase + PCL816_CONTROL); outb(0, dev->iobase + PCL816_MUX); outb(0, dev->iobase + PCL816_CLRINT); - outb(0xb0, dev->iobase + PCL816_CTRCTL); /* Stop pacer */ - outb(0x70, dev->iobase + PCL816_CTRCTL); - outb(0x30, dev->iobase + PCL816_CTRCTL); + + /* Stop pacer */ + i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 1, I8254_MODE0 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY); + outb(0, dev->iobase + PCL816_RANGE); } -/* -============================================================================== - Start/stop pacer onboard pacer -*/ -static void -start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, - unsigned int divisor2) -{ - outb(0x32, dev->iobase + PCL816_CTRCTL); - outb(0xff, dev->iobase + PCL816_CTR0); - outb(0x00, dev->iobase + PCL816_CTR0); - udelay(1); - - /* set counter 2 as mode 3 */ - outb(0xb4, dev->iobase + PCL816_CTRCTL); - /* set counter 1 as mode 3 */ - outb(0x74, dev->iobase + PCL816_CTRCTL); - udelay(1); - - if (mode == 1) { - dev_dbg(dev->class_dev, "mode %d, divisor1 %d, divisor2 %d\n", - mode, divisor1, divisor2); - outb(divisor2 & 0xff, dev->iobase + PCL816_CTR2); - outb((divisor2 >> 8) & 0xff, dev->iobase + PCL816_CTR2); - outb(divisor1 & 0xff, dev->iobase + PCL816_CTR1); - outb((divisor1 >> 8) & 0xff, dev->iobase + PCL816_CTR1); - } - - /* clear pending interrupts (just in case) */ -/* outb(0, dev->iobase + PCL816_CLRINT); */ -} - /* ============================================================================== Check if channel list from user is built correctly From 833b458a01eea7f4f0e5f1721141d5ad992da95c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:35 -0700 Subject: [PATCH 0362/1375] staging: comedi: pcl818: use 8253.h helpers Use the helper functions in 8253.h to clarify the timer programming. Move start_pacer() to remove the need for the forward declarations. Rename the function so it has namespace associated with the driver. Change the 'mode' parameter. This parameter is really a flag to the function indicating if the divisors should be loaded into the timers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 60 +++++++++++-------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 0ac07a90192a..2f62a49b369d 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -150,12 +150,8 @@ A word or two about DMA. Driver support DMA operations at two ways: /* W: PCL718 second D/A */ #define PCL718_DA2_LO 6 #define PCL718_DA2_HI 7 -/* counters */ -#define PCL818_CTR0 12 -#define PCL818_CTR1 13 -#define PCL818_CTR2 14 -/* W: counter control */ -#define PCL818_CTRCTL 15 + +#define PCL818_TIMER_BASE 0x0c /* W: fifo enable/disable */ #define PCL818_FI_ENABLE 6 @@ -364,8 +360,21 @@ static int check_channel_list(struct comedi_device *dev, static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2); + +static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters, + unsigned int divisor1, unsigned int divisor2) +{ + unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE; + + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + udelay(1); + + if (load_counters) { + i8254_write(timer_base, 0, 2, divisor2); + i8254_write(timer_base, 0, 1, divisor1); + } +} static unsigned int pcl818_ai_get_sample(struct comedi_device *dev, struct comedi_subdevice *s, @@ -833,7 +842,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, if (devpriv->irq_blocked) return -EBUSY; - start_pacer(dev, -1, 0, 0); /* stop pacer */ + pcl818_start_pacer(dev, false, 0, 0); seglen = check_channel_list(dev, s, devpriv->ai_chanlist, cmd->chanlist_len); @@ -902,30 +911,11 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, } } - start_pacer(dev, mode, divisor1, divisor2); + pcl818_start_pacer(dev, mode == 1, divisor1, divisor2); return 0; } -/* -============================================================================== - Start/stop pacer onboard pacer -*/ -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2) -{ - outb(0xb4, dev->iobase + PCL818_CTRCTL); - outb(0x74, dev->iobase + PCL818_CTRCTL); - udelay(1); - - if (mode == 1) { - outb(divisor2 & 0xff, dev->iobase + PCL818_CTR2); - outb((divisor2 >> 8) & 0xff, dev->iobase + PCL818_CTR2); - outb(divisor1 & 0xff, dev->iobase + PCL818_CTR1); - outb((divisor1 >> 8) & 0xff, dev->iobase + PCL818_CTR1); - } -} - /* ============================================================================== Check if channel list from user is builded correctly @@ -1167,7 +1157,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, #endif outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, dev->iobase + PCL818_CONTROL); /* Stop A/D */ udelay(1); - start_pacer(dev, -1, 0, 0); + pcl818_start_pacer(dev, false, 0, 0); outb(0, dev->iobase + PCL818_AD_LO); pcl818_ai_get_sample(dev, s, NULL); outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ @@ -1220,6 +1210,7 @@ static void pcl818_reset(struct comedi_device *dev) { const struct pcl818_board *board = comedi_board(dev); struct pcl818_private *devpriv = dev->private; + unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE; if (devpriv->usefifo) { /* FIFO shutdown */ outb(0, dev->iobase + PCL818_FI_INTCLR); @@ -1236,9 +1227,12 @@ static void pcl818_reset(struct comedi_device *dev) outb(0, dev->iobase + PCL818_CNTENABLE); outb(0, dev->iobase + PCL818_MUX); outb(0, dev->iobase + PCL818_CLRINT); - outb(0xb0, dev->iobase + PCL818_CTRCTL); /* Stop pacer */ - outb(0x70, dev->iobase + PCL818_CTRCTL); - outb(0x30, dev->iobase + PCL818_CTRCTL); + + /* Stop pacer */ + i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 1, I8254_MODE0 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY); + if (board->is_818) { outb(0, dev->iobase + PCL818_RANGE); } else { From 7440df0222bef37552dd5b3b7dd86e63f5029165 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:36 -0700 Subject: [PATCH 0363/1375] staging: comedi: pcl816: remove unneeded forward declarations These forward declarations are not needed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 998f7b49c1c7..e27457dd16fe 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -148,11 +148,6 @@ static void setup_channel_list(struct comedi_device *dev, static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static int pcl816_ai_cmdtest(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_cmd *cmd); -static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); - static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters, unsigned int divisor1, unsigned int divisor2) { From f8d863e4a9b7c7fefa9a1e743d5c290175e361bc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:37 -0700 Subject: [PATCH 0364/1375] staging: comedi: pcl812: don't calc the timer divisors twice The timer divisors are calculated in the (*do_cmdtest) before the (*do_cmd) is called by the comedi core. Save the values in the private data so they don't need to be recalced. Refactor pcl812_start_pacer() to use the values from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 34 ++++++++++--------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index b34814da34a0..0d7d3ae99514 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -529,6 +529,8 @@ struct pcl812_private { unsigned int last_dma_run; /* how many bytes to transfer on last DMA buffer */ unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */ unsigned int ao_readback[2]; /* data for AO readback */ + unsigned int divisor1; + unsigned int divisor2; }; static void setup_range_channel(struct comedi_device *dev, @@ -537,9 +539,9 @@ static void setup_range_channel(struct comedi_device *dev, static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers, - unsigned int divisor1, unsigned int divisor2) +static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers) { + struct pcl812_private *devpriv = dev->private; unsigned long timer_base = dev->iobase + PCL812_TIMER_BASE; i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); @@ -547,8 +549,8 @@ static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers, udelay(1); if (load_timers) { - i8254_write(timer_base, 0, 2, divisor2); - i8254_write(timer_base, 0, 1, divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); + i8254_write(timer_base, 0, 1, devpriv->divisor1); } } @@ -687,7 +689,7 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct pcl812_private *devpriv = dev->private; int err = 0; unsigned int flags; - int tmp, divisor1, divisor2; + int tmp; /* Step 1 : check if triggers are trivially valid */ @@ -743,7 +745,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, - &divisor1, &divisor2, + &devpriv->divisor1, + &devpriv->divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < board->ai_ns_min) cmd->convert_arg = board->ai_ns_min; @@ -762,20 +765,11 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, */ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - const struct pcl812_board *board = comedi_board(dev); struct pcl812_private *devpriv = dev->private; - unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes; struct comedi_cmd *cmd = &s->async->cmd; + unsigned int i, dma_flags, bytes; - if (cmd->convert_src == TRIG_TIMER) { - if (cmd->convert_arg < board->ai_ns_min) - cmd->convert_arg = board->ai_ns_min; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, - &divisor1, &divisor2, - &cmd->convert_arg, cmd->flags); - } - - pcl812_start_pacer(dev, false, 0, 0); + pcl812_start_pacer(dev, false); memcpy(devpriv->ai_chanlist, cmd->chanlist, sizeof(unsigned int) * cmd->scan_end_arg); @@ -869,7 +863,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) switch (cmd->convert_src) { case TRIG_TIMER: - pcl812_start_pacer(dev, true, divisor1, divisor2); + pcl812_start_pacer(dev, true); break; } @@ -1154,7 +1148,7 @@ static int pcl812_ai_cancel(struct comedi_device *dev, outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ /* Stop A/D */ outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); - pcl812_start_pacer(dev, false, 0, 0); + pcl812_start_pacer(dev, false); outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ return 0; } @@ -1182,7 +1176,7 @@ static void pcl812_reset(struct comedi_device *dev) case boardA821: outb(0, dev->iobase + PCL812_DA1_LO); outb(0, dev->iobase + PCL812_DA1_HI); - pcl812_start_pacer(dev, false, 0, 0); + pcl812_start_pacer(dev, false); outb(0, dev->iobase + PCL812_DO_HI); outb(0, dev->iobase + PCL812_DO_LO); outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); From f4985a79ca5ba6a2eb0edeb3125a7e763c3e6cc2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:39 -0700 Subject: [PATCH 0365/1375] staging: comedi: pcl818: don't calc the timer divisors twice The timer divisors are calculated in the (*do_cmdtest) before the (*do_cmd) is called by the comedi core. The extra sanity checks in the (*do_cmd) are not necessary, the values returned from i8253_cascade_ns_to_timer() will be greater than 1. Save the values in the private data so they don't need to be recalced. Refactor pcl818_start_pacer() to use the values from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 37 ++++++++----------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 2f62a49b369d..f8fe04cdb059 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -341,6 +341,8 @@ struct pcl818_private { unsigned int ai_timer2; unsigned char usefifo; /* 1=use fifo */ unsigned int ao_readback[2]; + unsigned int divisor1; + unsigned int divisor2; }; static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, /* used for gain list programming */ @@ -361,9 +363,9 @@ static int check_channel_list(struct comedi_device *dev, static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters, - unsigned int divisor1, unsigned int divisor2) +static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters) { + struct pcl818_private *devpriv = dev->private; unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE; i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); @@ -371,8 +373,8 @@ static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters, udelay(1); if (load_counters) { - i8254_write(timer_base, 0, 2, divisor2); - i8254_write(timer_base, 0, 1, divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); + i8254_write(timer_base, 0, 1, devpriv->divisor1); } } @@ -836,13 +838,12 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, { struct pcl818_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int divisor1 = 0, divisor2 = 0; unsigned int seglen; if (devpriv->irq_blocked) return -EBUSY; - pcl818_start_pacer(dev, false, 0, 0); + pcl818_start_pacer(dev, false); seglen = check_channel_list(dev, s, devpriv->ai_chanlist, cmd->chanlist_len); @@ -860,21 +861,6 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, devpriv->act_chanlist_pos = 0; devpriv->dma_runs_to_end = 0; - if (mode == 1) { - i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, - &divisor1, &divisor2, - &cmd->convert_arg, - TRIG_ROUND_NEAREST); - if (divisor1 == 1) { /* PCL718/818 crash if any divisor is set to 1 */ - divisor1 = 2; - divisor2 /= 2; - } - if (divisor2 == 1) { - divisor2 = 2; - divisor1 /= 2; - } - } - outb(0, dev->iobase + PCL818_CNTENABLE); /* enable pacer */ switch (devpriv->dma) { @@ -911,7 +897,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, } } - pcl818_start_pacer(dev, mode == 1, divisor1, divisor2); + pcl818_start_pacer(dev, mode == 1); return 0; } @@ -1021,7 +1007,7 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, const struct pcl818_board *board = comedi_board(dev); struct pcl818_private *devpriv = dev->private; int err = 0; - int tmp, divisor1 = 0, divisor2 = 0; + int tmp; /* Step 1 : check if triggers are trivially valid */ @@ -1070,7 +1056,8 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, - &divisor1, &divisor2, + &devpriv->divisor1, + &devpriv->divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < board->ns_min) cmd->convert_arg = board->ns_min; @@ -1157,7 +1144,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, #endif outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, dev->iobase + PCL818_CONTROL); /* Stop A/D */ udelay(1); - pcl818_start_pacer(dev, false, 0, 0); + pcl818_start_pacer(dev, false); outb(0, dev->iobase + PCL818_AD_LO); pcl818_ai_get_sample(dev, s, NULL); outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ From 81272ba1240eff306eb93c56bc5901d02ca43cc3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:40 -0700 Subject: [PATCH 0366/1375] staging: comedi: pcl812: use subdevice (*cancel) Use the subdevice (*cancel) operation to remove the need for a forward declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 0d7d3ae99514..d0708f8326df 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -536,8 +536,6 @@ struct pcl812_private { static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int rangechan, char wait); -static int pcl812_ai_cancel(struct comedi_device *dev, - struct comedi_subdevice *s); static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers) { @@ -911,7 +909,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) if (err) { dev_dbg(dev->class_dev, "A/D cmd IRQ without DRDY!\n"); - pcl812_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -935,7 +933,7 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) if (!(devpriv->ai_neverending)) /* all data sampled */ if (devpriv->ai_act_scan >= cmd->stop_arg) { - pcl812_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } } @@ -968,7 +966,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, if (!devpriv->ai_neverending) /* all data sampled */ if (devpriv->ai_act_scan >= cmd->stop_arg) { - pcl812_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; break; } From 6c42119d3d9d0f73017bbde7db6a11d10876805e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:42 -0700 Subject: [PATCH 0367/1375] staging: comedi: pcl818: use subdevice (*cancel) Use the subdevice (*cancel) operation to remove the need for a forward declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index f8fe04cdb059..47c87fb3eeff 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -360,9 +360,6 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan); -static int pcl818_ai_cancel(struct comedi_device *dev, - struct comedi_subdevice *s); - static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters) { struct pcl818_private *devpriv = dev->private; @@ -533,7 +530,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) } outb(0, dev->iobase + PCL818_STATUS); /* clear INT request */ comedi_error(dev, "A/D mode1/3 IRQ without DRDY!"); - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -547,7 +544,7 @@ conv_finish: "A/D mode1/3 IRQ - channel dropout %x!=%x !\n", chan, devpriv->act_chanlist[devpriv->act_chanlist_pos]); - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -564,7 +561,7 @@ conv_finish: if (!devpriv->neverending_ai) { if (devpriv->ai_act_scan == 0) { /* all data sampled */ - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } } @@ -615,7 +612,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) (ptr[bufptr] & 0xf), devpriv->act_chanlist[devpriv->act_chanlist_pos], devpriv->act_chanlist_pos); - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -635,7 +632,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) if (!devpriv->neverending_ai) if (devpriv->ai_act_scan == 0) { /* all data sampled */ - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); return IRQ_HANDLED; @@ -666,7 +663,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) if (lo & 4) { comedi_error(dev, "A/D mode1/3 FIFO overflow!"); - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -674,7 +671,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) if (lo & 1) { comedi_error(dev, "A/D mode1/3 FIFO interrupt without data!"); - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -692,7 +689,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) "A/D mode1/3 FIFO - channel dropout %d!=%d !\n", (lo & 0xf), devpriv->act_chanlist[devpriv->act_chanlist_pos]); - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -712,7 +709,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) if (!devpriv->neverending_ai) if (devpriv->ai_act_scan == 0) { /* all data sampled */ - pcl818_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); return IRQ_HANDLED; @@ -732,6 +729,7 @@ static irqreturn_t interrupt_pcl818(int irq, void *d) { struct comedi_device *dev = d; struct pcl818_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->read_subdev; if (!dev->attached) { comedi_error(dev, "premature interrupt"); @@ -750,7 +748,7 @@ static irqreturn_t interrupt_pcl818(int irq, void *d) */ devpriv->ai_act_scan = 0; devpriv->neverending_ai = 0; - pcl818_ai_cancel(dev, dev->read_subdev); + s->cancel(dev, s); } outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ From 00f921c7b9d380a39f3d46a262321a7350404196 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:43 -0700 Subject: [PATCH 0368/1375] staging: comedi: pcl818: remove analog output interrupt code The hardware does not have any analog output interrupt support. Remove the stubbed in code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 47c87fb3eeff..4b1506a4b68a 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -110,8 +110,6 @@ A word or two about DMA. Driver support DMA operations at two ways: #include "comedi_fc.h" #include "8253.h" -/* #define PCL818_MODE13_AO 1 */ - /* boards constants */ #define boardPCL818L 0 @@ -172,10 +170,6 @@ A word or two about DMA. Driver support DMA operations at two ways: #define INT_TYPE_AI3_INT 4 #define INT_TYPE_AI3_DMA 5 #define INT_TYPE_AI3_FIFO 6 -#ifdef PCL818_MODE13_AO -#define INT_TYPE_AO1_INT 7 -#define INT_TYPE_AO3_INT 8 -#endif #define MAGIC_DMA_WORD 0x5a5a @@ -766,11 +760,6 @@ static irqreturn_t interrupt_pcl818(int irq, void *d) case INT_TYPE_AI1_FIFO: case INT_TYPE_AI3_FIFO: return interrupt_pcl818_ai_mode13_fifo(irq, d); -#ifdef PCL818_MODE13_AO - case INT_TYPE_AO1_INT: - case INT_TYPE_AO3_INT: - return interrupt_pcl818_ao_mode13_int(irq, d); -#endif default: break; } @@ -1136,10 +1125,6 @@ static int pcl818_ai_cancel(struct comedi_device *dev, case INT_TYPE_AI3_INT: case INT_TYPE_AI1_FIFO: case INT_TYPE_AI3_FIFO: -#ifdef PCL818_MODE13_AO - case INT_TYPE_AO1_INT: - case INT_TYPE_AO3_INT: -#endif outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, dev->iobase + PCL818_CONTROL); /* Stop A/D */ udelay(1); pcl818_start_pacer(dev, false); From 7b822d011be55d1dec906fd857a5fdeef6e308ee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:44 -0700 Subject: [PATCH 0369/1375] staging: comedi: pcl818: remove 'ai_timer[12]' from private data These members of the private data are set but never used. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 4b1506a4b68a..874b9f24a65b 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -331,8 +331,6 @@ struct pcl818_private { unsigned int act_chanlist_pos; /* actual position in MUX list */ unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_data_len; /* len of data buffer */ - unsigned int ai_timer1; /* timers */ - unsigned int ai_timer2; unsigned char usefifo; /* 1=use fifo */ unsigned int ao_readback[2]; unsigned int divisor1; @@ -1077,8 +1075,6 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_data_len = s->async->prealloc_bufsz; - devpriv->ai_timer1 = 0; - devpriv->ai_timer2 = 0; if (cmd->stop_src == TRIG_COUNT) devpriv->neverending_ai = 0; @@ -1087,7 +1083,6 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 3 */ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */ - devpriv->ai_timer1 = cmd->convert_arg; retval = pcl818_ai_cmd_mode(1, dev, s); return retval; } From 4e2008616f25f7bf6a5be484d4d5d5e73d055f69 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:45 -0700 Subject: [PATCH 0370/1375] staging: comedi: pcl812: remove 'ai_chanlist' from private data This member of the private data is just a copy of the cmd->chanlist. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index d0708f8326df..8728a90e543b 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -517,7 +517,6 @@ struct pcl812_private { unsigned char ai_dma; /* =1 we use DMA */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int ai_act_scan; /* how many scans we finished */ - unsigned int ai_chanlist[MAX_CHANLIST_LEN]; /* our copy of channel/range list */ unsigned int ai_data_len; /* len of data buffer */ unsigned int dmapages; unsigned int hwdmasize; @@ -769,15 +768,13 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) pcl812_start_pacer(dev, false); - memcpy(devpriv->ai_chanlist, cmd->chanlist, - sizeof(unsigned int) * cmd->scan_end_arg); /* select first channel and range */ - setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); + setup_range_channel(dev, s, cmd->chanlist[0], 1); if (devpriv->dma) { /* check if we can use DMA transfer */ devpriv->ai_dma = 1; for (i = 1; i < cmd->chanlist_len; i++) - if (devpriv->ai_chanlist[0] != devpriv->ai_chanlist[i]) { + if (cmd->chanlist[0] != cmd->chanlist[i]) { /* we cann't use DMA :-( */ devpriv->ai_dma = 0; break; @@ -921,9 +918,8 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) next_chan = s->async->cur_chan + 1; if (next_chan >= cmd->chanlist_len) next_chan = 0; - if (devpriv->ai_chanlist[s->async->cur_chan] != - devpriv->ai_chanlist[next_chan]) - setup_range_channel(dev, s, devpriv->ai_chanlist[next_chan], 0); + if (cmd->chanlist[s->async->cur_chan] != cmd->chanlist[next_chan]) + setup_range_channel(dev, s, cmd->chanlist[next_chan], 0); outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ From 1784f30556a60b3692140e946f8338ce21035814 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:46 -0700 Subject: [PATCH 0371/1375] staging: comedi: pcl818: remove 'ai_chanlist' from private data This member of the private data is just a pointer to the cmd->chanlist. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 874b9f24a65b..4da0062f894a 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -329,7 +329,6 @@ struct pcl818_private { unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */ unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ - unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_data_len; /* len of data buffer */ unsigned char usefifo; /* 1=use fifo */ unsigned int ao_readback[2]; @@ -830,12 +829,10 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, pcl818_start_pacer(dev, false); - seglen = check_channel_list(dev, s, devpriv->ai_chanlist, - cmd->chanlist_len); + seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len); if (seglen < 1) return -EINVAL; - setup_channel_list(dev, s, devpriv->ai_chanlist, - cmd->chanlist_len, seglen); + setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, seglen); udelay(1); @@ -1073,7 +1070,6 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; int retval; - devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_data_len = s->async->prealloc_bufsz; if (cmd->stop_src == TRIG_COUNT) From f9d78e00f391672efa0f39bb863c95cb2aff2044 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:48 -0700 Subject: [PATCH 0372/1375] staging: comedi: pcl812: convert private data flags to bit-fields Convert the flags in the private data to bit-fields to save a bit of space. Rename the CamelCase 'use_MPC' member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 8728a90e543b..6e9d5f098d14 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -505,16 +505,10 @@ static const struct pcl812_board boardtypes[] = { struct pcl812_private { unsigned char dma; /* >0 use dma ( usedDMA channel) */ - unsigned char use_diff; /* =1 diff inputs */ - unsigned char use_MPC; /* 1=board uses MPC508A multiplexor */ - unsigned char use_ext_trg; /* 1=board uses external trigger */ unsigned char range_correction; /* =1 we must add 1 to range number */ unsigned char old_chan_reg; /* lastly used chan/gain pair */ unsigned char old_gain_reg; unsigned char mode_reg_int; /* there is stored INT number for some card */ - unsigned char ai_neverending; /* =1 we do unlimited AI */ - unsigned char ai_eos; /* 1=EOS wake up */ - unsigned char ai_dma; /* =1 we use DMA */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_data_len; /* len of data buffer */ @@ -530,6 +524,12 @@ struct pcl812_private { unsigned int ao_readback[2]; /* data for AO readback */ unsigned int divisor1; unsigned int divisor2; + unsigned int use_diff:1; + unsigned int use_mpc508:1; + unsigned int use_ext_trg:1; + unsigned int ai_dma:1; + unsigned int ai_eos:1; + unsigned int ai_neverending:1; }; static void setup_range_channel(struct comedi_device *dev, @@ -1104,7 +1104,7 @@ static void setup_range_channel(struct comedi_device *dev, devpriv->old_chan_reg = chan_reg; devpriv->old_gain_reg = gain_reg; - if (devpriv->use_MPC) { + if (devpriv->use_mpc508) { if (devpriv->use_diff) { chan_reg = chan_reg | 0x30; /* DIFF inputs */ } else { @@ -1380,7 +1380,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->cancel = pcl812_ai_cancel; } - devpriv->use_MPC = board->has_mpc508_mux; + devpriv->use_mpc508 = board->has_mpc508_mux; subdev++; From e5143adb18a90346d9f24229188f054853410998 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:50 -0700 Subject: [PATCH 0373/1375] staging: comedi: pcl818: convert private data flags to bit-fields Convert the flags in the private data to bit-fields to save a bit of space. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 4da0062f894a..8be7cb99708d 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -318,11 +318,8 @@ struct pcl818_private { int next_dma_buf; /* which DMA buffer will be used next round */ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ - unsigned char neverending_ai; /* if=1, then we do neverending record (you must use cancel()) */ unsigned int ns_min; /* manimal allowed delay between samples (in us) for actual card */ int i8253_osc_base; /* 1/frequency of on board oscilator in ns */ - int irq_blocked; /* 1=IRQ now uses any subdev */ - int irq_was_now_closed; /* when IRQ finish, there's stored int818_mode for last interrupt */ int ai_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ int ai_act_scan; /* how many scans we finished */ int ai_act_chan; /* actual position in actual scan */ @@ -330,10 +327,13 @@ struct pcl818_private { unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ unsigned int ai_data_len; /* len of data buffer */ - unsigned char usefifo; /* 1=use fifo */ unsigned int ao_readback[2]; unsigned int divisor1; unsigned int divisor2; + unsigned int usefifo:1; + unsigned int irq_blocked:1; + unsigned int irq_was_now_closed:1; + unsigned int neverending_ai:1; }; static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, /* used for gain list programming */ From c8bc43ec67cd113892c5eb9dd22d3bf35fb38662 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:52 -0700 Subject: [PATCH 0374/1375] staging: comedi: pcl818: rename 'irq_blocked' in private data This member in the private data is a flag that indicates that an analog input async command is currently running. Rename it to make this clear. The private data is kzalloc'ed in the attach so remove the unnecessary clearing of this flag. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 8be7cb99708d..2b2e7e698b91 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -331,7 +331,7 @@ struct pcl818_private { unsigned int divisor1; unsigned int divisor2; unsigned int usefifo:1; - unsigned int irq_blocked:1; + unsigned int ai_cmd_running:1; unsigned int irq_was_now_closed:1; unsigned int neverending_ai:1; }; @@ -727,7 +727,7 @@ static irqreturn_t interrupt_pcl818(int irq, void *d) return IRQ_HANDLED; } - if (devpriv->irq_blocked && devpriv->irq_was_now_closed) { + if (devpriv->ai_cmd_running && devpriv->irq_was_now_closed) { if ((devpriv->neverending_ai || (!devpriv->neverending_ai && devpriv->ai_act_scan > 0)) && (devpriv->ai_mode == INT_TYPE_AI1_DMA || @@ -763,7 +763,7 @@ static irqreturn_t interrupt_pcl818(int irq, void *d) outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */ - if (!devpriv->irq_blocked || !devpriv->ai_mode) { + if (!devpriv->ai_cmd_running || !devpriv->ai_mode) { comedi_error(dev, "bad IRQ!"); return IRQ_NONE; } @@ -824,7 +824,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; unsigned int seglen; - if (devpriv->irq_blocked) + if (devpriv->ai_cmd_running) return -EBUSY; pcl818_start_pacer(dev, false); @@ -838,7 +838,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, devpriv->ai_act_scan = cmd->stop_arg; devpriv->ai_act_chan = 0; - devpriv->irq_blocked = 1; + devpriv->ai_cmd_running = 1; devpriv->irq_was_now_closed = 0; devpriv->act_chanlist_pos = 0; devpriv->dma_runs_to_end = 0; @@ -1099,7 +1099,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, { struct pcl818_private *devpriv = dev->private; - if (devpriv->irq_blocked > 0) { + if (devpriv->ai_cmd_running) { devpriv->irq_was_now_closed = 1; switch (devpriv->ai_mode) { @@ -1128,7 +1128,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, outb(0, dev->iobase + PCL818_FI_FLUSH); outb(0, dev->iobase + PCL818_FI_ENABLE); } - devpriv->irq_blocked = 0; + devpriv->ai_cmd_running = 0; devpriv->neverending_ai = 0; devpriv->ai_mode = 0; devpriv->irq_was_now_closed = 0; @@ -1287,7 +1287,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->irq = it->options[1]; } - devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */ devpriv->ai_mode = 0; /* mode of irq */ /* we need an IRQ to do DMA on channel 3 or 1 */ From d4b6e550b6ba291f2a10721d3fc0105b7c05560e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:54 -0700 Subject: [PATCH 0375/1375] staging: comedi: pcl812: remove unnecessary function separation comments These comments are just added cruft. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 39 ------------------------- 1 file changed, 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 6e9d5f098d14..a4274af2dab9 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -609,9 +609,6 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, return ret ? ret : n; } -/* -============================================================================== -*/ static int pcl812_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -631,9 +628,6 @@ static int pcl812_ao_insn_write(struct comedi_device *dev, return i; } -/* -============================================================================== -*/ static int pcl812_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -648,9 +642,6 @@ static int pcl812_ao_insn_read(struct comedi_device *dev, return i; } -/* -============================================================================== -*/ static int pcl812_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -676,9 +667,6 @@ static int pcl812_do_insn_bits(struct comedi_device *dev, return insn->n; } -/* -============================================================================== -*/ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -757,9 +745,6 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, return 0; } -/* -============================================================================== -*/ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pcl812_private *devpriv = dev->private; @@ -870,9 +855,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -/* -============================================================================== -*/ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) { char err = 1; @@ -938,9 +920,6 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== -*/ static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subdevice *s, unsigned short *ptr, @@ -972,9 +951,6 @@ static void transfer_from_dma_buf(struct comedi_device *dev, comedi_event(dev, s); } -/* -============================================================================== -*/ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) { struct comedi_device *dev = d; @@ -1019,9 +995,6 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== -*/ static irqreturn_t interrupt_pcl812(int irq, void *d) { struct comedi_device *dev = d; @@ -1037,9 +1010,6 @@ static irqreturn_t interrupt_pcl812(int irq, void *d) return interrupt_pcl812_ai_int(irq, d); } -/* -============================================================================== -*/ static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) { struct pcl812_private *devpriv = dev->private; @@ -1084,9 +1054,6 @@ static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) return s->async->buf_write_count - s->async->buf_read_count; } -/* -============================================================================== -*/ static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int rangechan, char wait) @@ -1129,9 +1096,6 @@ static void setup_range_channel(struct comedi_device *dev, udelay(devpriv->max_812_ai_mode0_rangewait); } -/* -============================================================================== -*/ static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -1147,9 +1111,6 @@ static int pcl812_ai_cancel(struct comedi_device *dev, return 0; } -/* -============================================================================== -*/ static void pcl812_reset(struct comedi_device *dev) { const struct pcl812_board *board = comedi_board(dev); From 18c7a6df49d6a1b8d1d59b86bec0ee76e63b44b5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:56 -0700 Subject: [PATCH 0376/1375] staging: comedi: pcl818: remove unnecessary function separation comments These comments are just added cruft. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 66 ------------------------- 1 file changed, 66 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 2b2e7e698b91..65101970f99e 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -340,9 +340,6 @@ static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; -/* -============================================================================== -*/ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan, @@ -431,11 +428,6 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, return n; } -/* -============================================================================== - ANALOG OUTPUT MODE0, 818 cards - only one sample per call is supported -*/ static int pcl818_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -469,12 +461,6 @@ static int pcl818_ao_insn_write(struct comedi_device *dev, return n; } -/* -============================================================================== - DIGITAL INPUT MODE0, 818 cards - - only one sample per call is supported -*/ static int pcl818_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -500,11 +486,6 @@ static int pcl818_do_insn_bits(struct comedi_device *dev, return insn->n; } -/* -============================================================================== - analog input interrupt mode 1 & 3, 818 cards - one sample per interrupt version -*/ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d) { struct comedi_device *dev = d; @@ -560,10 +541,6 @@ conv_finish: return IRQ_HANDLED; } -/* -============================================================================== - analog input dma mode 1 & 3, 818 cards -*/ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) { struct comedi_device *dev = d; @@ -635,10 +612,6 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== - analog input interrupt mode 1 & 3, 818HD/HG cards -*/ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) { struct comedi_device *dev = d; @@ -712,10 +685,6 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== - INT procedure -*/ static irqreturn_t interrupt_pcl818(int irq, void *d) { struct comedi_device *dev = d; @@ -772,10 +741,6 @@ static irqreturn_t interrupt_pcl818(int irq, void *d) return IRQ_NONE; } -/* -============================================================================== - ANALOG INPUT MODE 1 or 3 DMA , 818 cards -*/ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev, struct comedi_subdevice *s) { @@ -813,10 +778,6 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev, } } -/* -============================================================================== - ANALOG INPUT MODE 1 or 3, 818 cards -*/ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, struct comedi_subdevice *s) { @@ -884,11 +845,6 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, return 0; } -/* -============================================================================== - Check if channel list from user is builded correctly - If it's ok, then program scan/gain logic -*/ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int n_chan) @@ -969,10 +925,6 @@ static void setup_channel_list(struct comedi_device *dev, dev->iobase + PCL818_MUX); } -/* -============================================================================== - Check if board is switched to SE (1) or DIFF(0) mode -*/ static int check_single_ended(unsigned int port) { if (inb(port + PCL818_STATUS) & 0x20) @@ -980,9 +932,6 @@ static int check_single_ended(unsigned int port) return 0; } -/* -============================================================================== -*/ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -1061,9 +1010,6 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } -/* -============================================================================== -*/ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pcl818_private *devpriv = dev->private; @@ -1090,10 +1036,6 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -1; } -/* -============================================================================== - cancel any mode 1-4 AI -*/ static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -1140,10 +1082,6 @@ end: return 0; } -/* -============================================================================== - chech for PCL818 -*/ static int pcl818_check(unsigned long iobase) { outb(0x00, iobase + PCL818_MUX); @@ -1163,10 +1101,6 @@ static int pcl818_check(unsigned long iobase) return 0; /* ok, card exist */ } -/* -============================================================================== - reset whole PCL-818 cards -*/ static void pcl818_reset(struct comedi_device *dev) { const struct pcl818_board *board = comedi_board(dev); From 243e7146c8ed16cbda71126168fe73acab7c62d2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:57 -0700 Subject: [PATCH 0377/1375] staging: comedi: pcl818: tidy up pcl818_check() This function probes a number of the boards registers during the (*attach) to verify that it is actually a PCL-818 compatible board. For aesthetics, move the function closer to the (*attach). Refactor the function to return an errno if fails. Change the errno from -EIO to -ENODEV and remove the unnecessary comedi_error() noise. Make sure the CONTROL register is reset to a known state after the check. The 0x18 value actually defines an invalid interrupt selection and sets an undefined bit. Add a couple comments to clarify the magic values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 50 +++++++++++++------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 65101970f99e..56a5de712e87 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -1082,25 +1082,6 @@ end: return 0; } -static int pcl818_check(unsigned long iobase) -{ - outb(0x00, iobase + PCL818_MUX); - udelay(1); - if (inb(iobase + PCL818_MUX) != 0x00) - return 1; /* there isn't card */ - outb(0x55, iobase + PCL818_MUX); - udelay(1); - if (inb(iobase + PCL818_MUX) != 0x55) - return 1; /* there isn't card */ - outb(0x00, iobase + PCL818_MUX); - udelay(1); - outb(0x18, iobase + PCL818_CONTROL); - udelay(1); - if (inb(iobase + PCL818_CONTROL) != 0x18) - return 1; /* there isn't card */ - return 0; /* ok, card exist */ -} - static void pcl818_reset(struct comedi_device *dev) { const struct pcl818_board *board = comedi_board(dev); @@ -1187,6 +1168,30 @@ static void pcl818_set_ai_range_table(struct comedi_device *dev, } } +static int pcl818_check(struct comedi_device *dev) +{ + /* the MUX register should return the same value written */ + outb(0x00, dev->iobase + PCL818_MUX); + if (inb(dev->iobase + PCL818_MUX) != 0x00) + return -ENODEV; + outb(0x55, dev->iobase + PCL818_MUX); + if (inb(dev->iobase + PCL818_MUX) != 0x55) + return -ENODEV; + + /* reset the MUX register to a known state */ + outb(0x00, dev->iobase + PCL818_MUX); + + /* the CONTROL register should return the same value written */ + outb(0x18, dev->iobase + PCL818_CONTROL); + if (inb(dev->iobase + PCL818_CONTROL) != 0x18) + return -ENODEV; + + /* reset the CONTROL register to a known state */ + outb(0x00, dev->iobase + PCL818_CONTROL); + + return 0; +} + static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl818_board *board = comedi_board(dev); @@ -1208,10 +1213,9 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - if (pcl818_check(dev->iobase)) { - comedi_error(dev, "I can't detect board. FAIL!\n"); - return -EIO; - } + ret = pcl818_check(dev); + if (ret) + return ret; /* we can use IRQ 2-7 for async command support */ if (it->options[1] >= 2 && it->options[1] <= 7) { From c9968ed9fe88968efa68f5d1a75ab8aa02edac1c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:27:59 -0700 Subject: [PATCH 0378/1375] staging: comedi: pcl812: allocate private data before requesting the I/O region To better match the pcl818 and pcl816 drivers, allocate the private data before calling comedi_request_region(). Signed-off-by: H Hartley Sweeten 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 a4274af2dab9..3a0dad82d510 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1247,14 +1247,14 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) int ret; int i; - ret = comedi_request_region(dev, it->options[0], 0x10); - if (ret) - return ret; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; + ret = comedi_request_region(dev, it->options[0], 0x10); + if (ret) + return ret; + if ((1 << it->options[1]) & board->IRQbits) { ret = request_irq(it->options[1], interrupt_pcl812, 0, dev->board_name, dev); From 53693d9068735ccb4a2c304f60c88e168895029d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Feb 2014 14:28:01 -0700 Subject: [PATCH 0379/1375] staging: comedi: pcl818: kzalloc'ed memory does not need to be cleared The private data is kzalloc'ed in the (*attach). There is no need to initialize and the members to 0. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 56a5de712e87..861f51976fd7 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -1225,8 +1225,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->irq = it->options[1]; } - devpriv->ai_mode = 0; /* mode of irq */ - /* we need an IRQ to do DMA on channel 3 or 1 */ if (dev->irq && board->has_dma && (it->options[2] == 3 || it->options[2] == 1)) { From a9f488831cb4e95d0c6464e2c68cf87cd75dfd87 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 17 Feb 2014 14:13:08 +0000 Subject: [PATCH 0380/1375] staging: et131x: fix allocation failures We should check the ring allocations don't fail. If we get a fail we need to clean up properly. The allocator assumes the deallocator will be used on failure, but it isn't. Make sure the right deallocator is always called and add a missing check against fbr allocation failure. [v2]: Correct check logic Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 641350039242..cc600df69ec6 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -2124,7 +2124,11 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) /* Alloc memory for the lookup table */ rx_ring->fbr[0] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); + if (rx_ring->fbr[0] == NULL) + return -ENOMEM; rx_ring->fbr[1] = kmalloc(sizeof(struct fbr_lookup), GFP_KERNEL); + if (rx_ring->fbr[1] == NULL) + return -ENOMEM; /* The first thing we will do is configure the sizes of the buffer * rings. These will change based on jumbo packet support. Larger @@ -2289,7 +2293,7 @@ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) for (id = 0; id < NUM_FBRS; id++) { fbr = rx_ring->fbr[id]; - if (!fbr->ring_virtaddr) + if (!fbr || !fbr->ring_virtaddr) continue; /* First the packet memory */ @@ -3591,6 +3595,7 @@ static int et131x_adapter_memory_alloc(struct et131x_adapter *adapter) if (status) { dev_err(&adapter->pdev->dev, "et131x_tx_dma_memory_alloc FAILED\n"); + et131x_tx_dma_memory_free(adapter); return status; } /* Receive buffer memory allocation */ @@ -3598,7 +3603,7 @@ static int et131x_adapter_memory_alloc(struct et131x_adapter *adapter) if (status) { dev_err(&adapter->pdev->dev, "et131x_rx_dma_memory_alloc FAILED\n"); - et131x_tx_dma_memory_free(adapter); + et131x_adapter_memory_free(adapter); return status; } From 11975225a2b9bcba51e413a99b399f620573730d Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 19 Feb 2014 01:36:46 -0600 Subject: [PATCH 0381/1375] Staging: comedi: addi-data: cleanup comments in hwdrv_apci1564.c hwdrv_apci1564.c had a lot of commented out conditional statements that were often identical to other un-commented out statements nearby, so it should be safe to just delete all of these commented out lines. This patch also converts the remaining comments to the preferred kernel style for comments. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 93 ++++++++----------- 1 file changed, 38 insertions(+), 55 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 84668544f52d..ff556cc2eeae 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -138,9 +138,8 @@ static int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct addi_private *devpriv = dev->private; devpriv->tsk_Current = current; - /*******************************/ + /* Set the digital input logic */ - /*******************************/ if (data[0] == ADDIDATA_ENABLE) { data[2] = data[2] << 4; data[3] = data[3] << 4; @@ -154,13 +153,13 @@ static int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, outl(0x4, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } /* if (data[1] == ADDIDATA_OR) */ + } else { outl(0x6, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } /* else if (data[1] == ADDIDATA_OR) */ - } /* if (data[0] == ADDIDATA_ENABLE) */ + } + } else { outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + @@ -171,7 +170,7 @@ static int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } /* else if (data[0] == ADDIDATA_ENABLE) */ + } return insn->n; } @@ -225,25 +224,25 @@ static int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, comedi_error(dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; - } /* if ((data[0]!=0) && (data[0]!=1)) */ + } if (data[0]) { devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } /* if (data[0]) */ + } else { devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } /* else if (data[0]) */ + } if (data[1] == ADDIDATA_ENABLE) { ul_Command = ul_Command | 0x1; - } /* if (data[1] == ADDIDATA_ENABLE) */ + } else { ul_Command = ul_Command & 0xFFFFFFFE; - } /* else if (data[1] == ADDIDATA_ENABLE) */ + } if (data[2] == ADDIDATA_ENABLE) { ul_Command = ul_Command | 0x2; - } /* if (data[2] == ADDIDATA_ENABLE) */ + } else { ul_Command = ul_Command & 0xFFFFFFFD; - } /* else if (data[2] == ADDIDATA_ENABLE) */ + } outl(ul_Command, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT); @@ -323,7 +322,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, outl(data[3], devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_RELOAD_VALUE); - } /* if (data[0]==ADDIDATA_WATCHDOG) */ + } else if (data[0] == ADDIDATA_TIMER) { /* First Stop The Timer */ ul_Command1 = @@ -357,13 +356,12 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, outl(0x0, devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_IRQ); - } /* if (data[1]==1) */ + } else { outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* disable Timer interrupt */ - } /* else if (data[1]==1) */ + } /* Loading Timebase */ - outl(data[2], devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_TIMEBASE); @@ -379,7 +377,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* mode 2 */ - } /* else if (data[0]==ADDIDATA_TIMER) */ + } else if (data[0] == ADDIDATA_COUNTER) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; devpriv->b_ModeSelectRegister = data[5]; @@ -391,14 +389,11 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); /* Stop The Timer */ - /************************/ /* Set the reload value */ - /************************/ outl(data[3], devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_RELOAD_VALUE); - /******************************/ /* Set the mode : */ /* - Disable the hardware */ /* - Disable the counter mode */ @@ -406,7 +401,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, /* - Disable the reset */ /* - Disable the timer mode */ /* - Enable the counter mode */ - /******************************/ + ul_Command1 = (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (unsigned int) ((unsigned int) data[4] << 16UL); @@ -420,17 +415,15 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); - /*****************************/ /* Set the Up/Down selection */ - /*****************************/ ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18); outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); - } /* else if (data[0]==ADDIDATA_COUNTER) */ + } else { printk(" Invalid subdevice."); - } /* else if (data[0]==ADDIDATA_WATCHDOG) */ + } return insn->n; } @@ -489,8 +482,8 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d default: printk("\nSpecified functionality does not exist\n"); return -EINVAL; - } /* switch (data[1]) */ - } /* if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ + } + } if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { if (data[1] == 1) { ul_Command1 = @@ -502,7 +495,7 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); - } /* if (data[1]==1) */ + } else if (data[1] == 0) { /* Stop The Timer */ @@ -513,8 +506,8 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); - } /* else if(data[1]==0) */ - } /* if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ + } + } if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { ul_Command1 = inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister - @@ -522,16 +515,16 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d if (data[1] == 1) { /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - } /* if (data[1] == 1) */ + } else if (data[1] == 0) { /* Stops the Counter subdevice */ ul_Command1 = 0; - } /* else if (data[1] == 0) */ + } else if (data[1] == 2) { /* Clears the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; - } /* else if (data[1] == 3) */ + } outl(ul_Command1, devpriv->iobase + ((devpriv->b_ModeSelectRegister - 1) * 0x20) + APCI1564_TCW_PROG); @@ -577,7 +570,7 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG); - } /* if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ + } else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { /* Stores the status of the Timer */ data[0] = @@ -586,7 +579,7 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, /* Stores the Actual value of the Timer */ data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER); - } /* else if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ + } else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { /* Read the Counter Actual Value. */ data[0] = @@ -597,31 +590,23 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister - 1) * 0x20) + APCI1564_TCW_TRIG_STATUS); - /***********************************/ /* Get the software trigger status */ - /***********************************/ data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); - /***********************************/ /* Get the hardware trigger status */ - /***********************************/ data[2] = (unsigned char) ((ul_Command1 >> 2) & 1); - /*********************************/ /* Get the software clear status */ - /*********************************/ data[3] = (unsigned char) ((ul_Command1 >> 3) & 1); - /***************************/ /* Get the overflow status */ - /***************************/ data[4] = (unsigned char) ((ul_Command1 >> 0) & 1); - } /* else if (devpriv->b_TimerSelectMode==ADDIDATA_COUNTER) */ + } else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG) && (devpriv->b_TimerSelectMode != ADDIDATA_COUNTER)) { printk("\n Invalid Subdevice !!!\n"); - } /* else if ((devpriv->b_TimerSelectMode!=ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode!=ADDIDATA_WATCHDOG)&& (devpriv->b_TimerSelectMode!=ADDIDATA_COUNTER)) */ + } return insn->n; } @@ -695,7 +680,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) if (ui_DI == 0 && ui_DO == 0 && ui_Timer == 0 && ui_C1 == 0 && ui_C2 == 0 && ui_C3 == 0 && ui_C4 == 0) { printk("\nInterrupt from unknown source\n"); - } /* if(ui_DI==0 && ui_DO==0 && ui_Timer==0 && ui_C1==0 && ui_C2==0 && ui_C3==0 && ui_C4==0) */ + } if (ui_DI == 1) { ui_DI = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + @@ -724,8 +709,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) /* Sends signal to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); - - } /* if (ui_DO) */ + } if (ui_Timer == 1) { devpriv->b_TimerSelectMode = ADDIDATA_TIMER; @@ -748,8 +732,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); } - }/* if (ui_Timer == 1) */ - + } if (ui_C1 == 1) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; @@ -771,7 +754,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) devpriv->iobase + APCI1564_COUNTER1 + APCI1564_TCW_PROG); } - } /* if (ui_C1 == 1) */ + } if (ui_C2 == 1) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; @@ -793,7 +776,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) devpriv->iobase + APCI1564_COUNTER2 + APCI1564_TCW_PROG); } - } /* if ((ui_C2 == 1) */ + } if (ui_C3 == 1) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; @@ -815,7 +798,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) devpriv->iobase + APCI1564_COUNTER3 + APCI1564_TCW_PROG); } - } /* if ((ui_C3 == 1) */ + } if (ui_C4 == 1) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; @@ -837,7 +820,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_PROG); } - } /* if (ui_C4 == 1) */ + } return; } From 988bcffd2632c29d1b1bacf686989b1191dd137d Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 19 Feb 2014 01:37:42 -0600 Subject: [PATCH 0382/1375] Staging: comedi: addi-data: cleanup brace usage in hwdrv_apci1564.c hwdrv_apci1564.c had many single statments wrapped in braces, so we can delete these. Also, some else statements were improperly placed, fix these too. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 58 +++++++------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index ff556cc2eeae..66e6e68ee3d7 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -153,14 +153,12 @@ static int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, outl(0x4, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); - } - else { + } else { outl(0x6, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_IRQ); } - } - else { + } else { outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP + APCI1564_DIGITAL_IP_INTERRUPT_MODE1); @@ -225,24 +223,22 @@ static int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; } - if (data[0]) { + + if (data[0]) devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } - else { + else devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } - if (data[1] == ADDIDATA_ENABLE) { + + if (data[1] == ADDIDATA_ENABLE) ul_Command = ul_Command | 0x1; - } - else { + else ul_Command = ul_Command & 0xFFFFFFFE; - } - if (data[2] == ADDIDATA_ENABLE) { + + if (data[2] == ADDIDATA_ENABLE) ul_Command = ul_Command | 0x2; - } - else { + else ul_Command = ul_Command & 0xFFFFFFFD; - } + outl(ul_Command, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP + APCI1564_DIGITAL_OP_INTERRUPT); @@ -322,8 +318,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, outl(data[3], devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG + APCI1564_TCW_RELOAD_VALUE); - } - else if (data[0] == ADDIDATA_TIMER) { + } else if (data[0] == ADDIDATA_TIMER) { /* First Stop The Timer */ ul_Command1 = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + @@ -356,8 +351,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, outl(0x0, devpriv->iobase + APCI1564_COUNTER4 + APCI1564_TCW_IRQ); - } - else { + } else { outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* disable Timer interrupt */ } @@ -377,8 +371,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); /* mode 2 */ - } - else if (data[0] == ADDIDATA_COUNTER) { + } else if (data[0] == ADDIDATA_COUNTER) { devpriv->b_TimerSelectMode = ADDIDATA_COUNTER; devpriv->b_ModeSelectRegister = data[5]; @@ -420,8 +413,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, outl(ul_Command1, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); - } - else { + } else { printk(" Invalid subdevice."); } @@ -495,8 +487,7 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d outl(ul_Command1, devpriv->i_IobaseAmcc + APCI1564_TIMER + APCI1564_TCW_PROG); - } - else if (data[1] == 0) { + } else if (data[1] == 0) { /* Stop The Timer */ ul_Command1 = @@ -515,13 +506,11 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d if (data[1] == 1) { /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - } - else if (data[1] == 0) { + } else if (data[1] == 0) { /* Stops the Counter subdevice */ ul_Command1 = 0; - } - else if (data[1] == 2) { + } else if (data[1] == 2) { /* Clears the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; } @@ -570,8 +559,7 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP_WATCHDOG); - } - else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { + } else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { /* Stores the status of the Timer */ data[0] = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER + @@ -579,8 +567,7 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, /* Stores the Actual value of the Timer */ data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER); - } - else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { + } else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { /* Read the Counter Actual Value. */ data[0] = inl(devpriv->iobase + ((devpriv->b_ModeSelectRegister - @@ -601,8 +588,7 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, /* Get the overflow status */ data[4] = (unsigned char) ((ul_Command1 >> 0) & 1); - } - else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) + } else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG) && (devpriv->b_TimerSelectMode != ADDIDATA_COUNTER)) { printk("\n Invalid Subdevice !!!\n"); From 614bd02fc0113c5b272843731f69005484c77e2a Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 19 Feb 2014 01:37:54 -0600 Subject: [PATCH 0383/1375] Staging: comedi: addi-data: replace printk() with dev_err() in hwdrv_apci1564.c There were a small handful of printk() calls in hwdrv_apci1564.c. It is generally better to use dev_err() for error messages instead, so I switched all the printk() calls out, as well as cleaned up the error strings. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 66e6e68ee3d7..21dd028c4461 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -414,7 +414,7 @@ static int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, devpriv->iobase + ((data[5] - 1) * 0x20) + APCI1564_TCW_PROG); } else { - printk(" Invalid subdevice."); + dev_err(dev->class_dev, "Invalid subdevice.\n"); } return insn->n; @@ -472,7 +472,7 @@ static int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *d APCI1564_TCW_PROG); break; default: - printk("\nSpecified functionality does not exist\n"); + dev_err(dev->class_dev, "Specified functionality does not exist.\n"); return -EINVAL; } } @@ -591,7 +591,7 @@ static int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, } else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG) && (devpriv->b_TimerSelectMode != ADDIDATA_COUNTER)) { - printk("\n Invalid Subdevice !!!\n"); + dev_err(dev->class_dev, "Invalid Subdevice!\n"); } return insn->n; } @@ -665,7 +665,7 @@ static void v_APCI1564_Interrupt(int irq, void *d) APCI1564_TCW_IRQ) & 0x1; if (ui_DI == 0 && ui_DO == 0 && ui_Timer == 0 && ui_C1 == 0 && ui_C2 == 0 && ui_C3 == 0 && ui_C4 == 0) { - printk("\nInterrupt from unknown source\n"); + dev_err(dev->class_dev, "Interrupt from unknown source.\n"); } if (ui_DI == 1) { From 6777877c4f1bc650a9d04cae8cbcf0be13cbd7b7 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 19 Feb 2014 01:38:10 -0600 Subject: [PATCH 0384/1375] Staging: comedi: addi-data: don't initialize a static variable to 0 In hwdrv_apci1564.c, one static variable is zero initialized. This is unneeded and redundant, so we remove the initialization. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 21dd028c4461..2b47fa17d601 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -100,7 +100,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI1564_TCW_WARN_TIMEBASE 28 /* Global variables */ -static unsigned int ui_InterruptStatus_1564 = 0; +static unsigned int ui_InterruptStatus_1564; static unsigned int ui_InterruptData, ui_Type; /* From d39c5ed7cb06b04d99f2b8f88ef70a657fe7b7ee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:20 -0700 Subject: [PATCH 0385/1375] staging: comedi: pcl816: remove 'ai_ns_min' from boardinfo This member of the boardinfo is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index e27457dd16fe..cabc5fe26df6 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -87,7 +87,6 @@ static const struct comedi_lrange range_pcl816 = { struct pcl816_board { const char *name; - unsigned int ai_ns_min; int n_aochan; unsigned int IRQbits; int ai_maxdata; @@ -98,7 +97,6 @@ struct pcl816_board { static const struct pcl816_board boardtypes[] = { { .name = "pcl816", - .ai_ns_min = 10000, .n_aochan = 1, .IRQbits = 0x00fc, .ai_maxdata = 0xffff, @@ -106,7 +104,6 @@ static const struct pcl816_board boardtypes[] = { .ai_chanlist = 1024, }, { .name = "pcl814b", - .ai_ns_min = 10000, .n_aochan = 1, .IRQbits = 0x00fc, .ai_maxdata = 0x3fff, @@ -408,7 +405,6 @@ static irqreturn_t interrupt_pcl816(int irq, void *d) static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - const struct pcl816_board *board = comedi_board(dev); int err = 0; int tmp, divisor1 = 0, divisor2 = 0; @@ -440,8 +436,7 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); if (cmd->convert_src == TRIG_TIMER) - err |= cfc_check_trigger_arg_min(&cmd->convert_arg, - board->ai_ns_min); + err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); else /* TRIG_EXT */ err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); @@ -462,8 +457,8 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg < board->ai_ns_min) - cmd->convert_arg = board->ai_ns_min; + if (cmd->convert_arg < 10000) + cmd->convert_arg = 10000; if (tmp != cmd->convert_arg) err++; } @@ -485,7 +480,6 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - const struct pcl816_board *board = comedi_board(dev); struct pcl816_private *devpriv = dev->private; unsigned int divisor1 = 0, divisor2 = 0, dma_flags, bytes, dmairq; struct comedi_cmd *cmd = &s->async->cmd; @@ -495,8 +489,8 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EBUSY; if (cmd->convert_src == TRIG_TIMER) { - if (cmd->convert_arg < board->ai_ns_min) - cmd->convert_arg = board->ai_ns_min; + if (cmd->convert_arg < 10000) + cmd->convert_arg = 10000; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &divisor1, &divisor2, From 31baee58a6c797f399e8b673e5db96a7aeccef44 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:21 -0700 Subject: [PATCH 0386/1375] staging: comedi: pcl816: remove 'n_aochan' from boardinfo This member of the boardinfo is the same for all board types. Remove this data from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index cabc5fe26df6..b76e9d6f9386 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -87,7 +87,6 @@ static const struct comedi_lrange range_pcl816 = { struct pcl816_board { const char *name; - int n_aochan; unsigned int IRQbits; int ai_maxdata; int ao_maxdata; @@ -97,14 +96,12 @@ struct pcl816_board { static const struct pcl816_board boardtypes[] = { { .name = "pcl816", - .n_aochan = 1, .IRQbits = 0x00fc, .ai_maxdata = 0xffff, .ao_maxdata = 0xffff, .ai_chanlist = 1024, }, { .name = "pcl814b", - .n_aochan = 1, .IRQbits = 0x00fc, .ai_maxdata = 0x3fff, .ao_maxdata = 0x3fff, @@ -890,7 +887,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) #if 0 subdevs[1] = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND; - s->n_chan = board->n_aochan; + s->n_chan = 1; s->maxdata = board->ao_maxdata; s->range_table = &range_pcl816; break; From e5f376df8b13cf09220a8003469b10a9b8095d3c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:22 -0700 Subject: [PATCH 0387/1375] staging: comedi: pcl816: clarify irq request in pcl816_attach() All the board types can use IRQ 2-7 for async command support. Remove the 'IRQbits', which is a mask of the valid IRQs, from the boardinfo and refactor pcl816_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index b76e9d6f9386..cfda332ef715 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -87,7 +87,6 @@ static const struct comedi_lrange range_pcl816 = { struct pcl816_board { const char *name; - unsigned int IRQbits; int ai_maxdata; int ao_maxdata; int ai_chanlist; @@ -96,13 +95,11 @@ struct pcl816_board { static const struct pcl816_board boardtypes[] = { { .name = "pcl816", - .IRQbits = 0x00fc, .ai_maxdata = 0xffff, .ao_maxdata = 0xffff, .ai_chanlist = 1024, }, { .name = "pcl814b", - .IRQbits = 0x00fc, .ai_maxdata = 0x3fff, .ao_maxdata = 0x3fff, .ai_chanlist = 1024, @@ -827,7 +824,8 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv) return -ENOMEM; - if ((1 << it->options[1]) & board->IRQbits) { + /* we can use IRQ 2-7 for async command support */ + if (it->options[1] >= 2 && it->options[1] <= 7) { ret = request_irq(it->options[1], interrupt_pcl816, 0, dev->board_name, dev); if (ret == 0) From f23068ec57acd6fb0bf4c69075072350a5ff849a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:23 -0700 Subject: [PATCH 0388/1375] staging: comedi: pcl816: don't calc the timer divisors twice The timer divisors are calculated in the (*do_cmdtest) before the (*do_cmd) is called by the comedi core. The extra sanity checks in the (*do_cmd) are not necessary, the values returned from i8253_cascade_ns_to_timer() will be greater than 1. Save the values in the private data so they don't need to be recalced. Refactor pcl816_start_pacer() to use the values from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 41 ++++++++----------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index cfda332ef715..a8302daf4301 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -125,6 +125,8 @@ struct pcl816_private { unsigned int ai_act_chanlist_len; /* how long is actual MUX list */ unsigned int ai_act_chanlist_pos; /* actual position in MUX list */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ + unsigned int divisor1; + unsigned int divisor2; }; /* @@ -139,9 +141,9 @@ static void setup_channel_list(struct comedi_device *dev, static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); -static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters, - unsigned int divisor1, unsigned int divisor2) +static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters) { + struct pcl816_private *devpriv = dev->private; unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE; i8254_set_mode(timer_base, 0, 0, I8254_MODE1 | I8254_BINARY); @@ -153,8 +155,8 @@ static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters, udelay(1); if (load_counters) { - i8254_write(timer_base, 0, 2, divisor2); - i8254_write(timer_base, 0, 1, divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); + i8254_write(timer_base, 0, 1, devpriv->divisor1); } } @@ -399,8 +401,9 @@ static irqreturn_t interrupt_pcl816(int irq, void *d) static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { + struct pcl816_private *devpriv = dev->private; int err = 0; - int tmp, divisor1 = 0, divisor2 = 0; + int tmp; /* Step 1 : check if triggers are trivially valid */ @@ -449,7 +452,8 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &divisor1, &divisor2, + &devpriv->divisor1, + &devpriv->divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < 10000) cmd->convert_arg = 10000; @@ -475,33 +479,14 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pcl816_private *devpriv = dev->private; - unsigned int divisor1 = 0, divisor2 = 0, dma_flags, bytes, dmairq; struct comedi_cmd *cmd = &s->async->cmd; + unsigned int dma_flags, bytes, dmairq; unsigned int seglen; if (devpriv->irq_blocked) return -EBUSY; - if (cmd->convert_src == TRIG_TIMER) { - if (cmd->convert_arg < 10000) - cmd->convert_arg = 10000; - - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &divisor1, &divisor2, - &cmd->convert_arg, cmd->flags); - - /* PCL816 crash if any divisor is set to 1 */ - if (divisor1 == 1) { - divisor1 = 2; - divisor2 /= 2; - } - if (divisor2 == 1) { - divisor2 = 2; - divisor1 /= 2; - } - } - - pcl816_start_pacer(dev, false, 0, 0); + pcl816_start_pacer(dev, false); seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len); if (seglen < 1) @@ -549,7 +534,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) enable_dma(devpriv->dma); } - pcl816_start_pacer(dev, true, divisor1, divisor2); + pcl816_start_pacer(dev, true); dmairq = ((devpriv->dma & 0x3) << 4) | (dev->irq & 0x7); switch (cmd->convert_src) { From a3ab029e8389de87f7e0b7af0fda21c5041d877f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:24 -0700 Subject: [PATCH 0389/1375] staging: comedi: pcl816: use subdevice (*cancel) Use the subdevice (*cancel) operation to remove the need for a forward declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index a8302daf4301..0d2eaa9fc04c 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -138,8 +138,6 @@ static int check_channel_list(struct comedi_device *dev, static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int seglen); -static int pcl816_ai_cancel(struct comedi_device *dev, - struct comedi_subdevice *s); static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters) { @@ -242,7 +240,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) if (!timeout) { /* timeout, bail error */ outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ comedi_error(dev, "A/D mode1/3 IRQ without DRDY!"); - pcl816_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; comedi_event(dev, s); return IRQ_HANDLED; @@ -266,7 +264,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) /* all data sampled */ if (devpriv->ai_act_scan >= cmd->stop_arg) { /* all data sampled */ - pcl816_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } comedi_event(dev, s); @@ -306,7 +304,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, if (!devpriv->ai_neverending) /* all data sampled */ if (devpriv->ai_act_scan >= cmd->stop_arg) { - pcl816_ai_cancel(dev, s); + s->cancel(dev, s); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_BLOCK; break; From 0f9c4c7e38c7e1f6669093e8220067fafb8dcae6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:25 -0700 Subject: [PATCH 0390/1375] staging: comedi: pcl816: remove 'ai_act_chanlist_{len, pos}' from private data These members of the private data don't do anything usefull. Just remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 0d2eaa9fc04c..54d75a7f866e 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -122,8 +122,6 @@ struct pcl816_private { int int816_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ int ai_act_scan; /* how many scans we finished */ unsigned int ai_act_chanlist[16]; /* MUX setting for actual AI operations */ - unsigned int ai_act_chanlist_len; /* how long is actual MUX list */ - unsigned int ai_act_chanlist_pos; /* actual position in MUX list */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int divisor1; unsigned int divisor2; @@ -251,9 +249,6 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ - if (++devpriv->ai_act_chanlist_pos >= devpriv->ai_act_chanlist_len) - devpriv->ai_act_chanlist_pos = 0; - s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; @@ -290,11 +285,6 @@ static void transfer_from_dma_buf(struct comedi_device *dev, comedi_buf_put(s->async, ptr[bufptr++]); - if (++devpriv->ai_act_chanlist_pos >= - devpriv->ai_act_chanlist_len) { - devpriv->ai_act_chanlist_pos = 0; - } - s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; @@ -769,9 +759,6 @@ setup_channel_list(struct comedi_device *dev, struct pcl816_private *devpriv = dev->private; unsigned int i; - devpriv->ai_act_chanlist_len = seglen; - devpriv->ai_act_chanlist_pos = 0; - for (i = 0; i < seglen; i++) { /* store range list to card */ devpriv->ai_act_chanlist[i] = CR_CHAN(chanlist[i]); outb(CR_CHAN(chanlist[0]) & 0xf, dev->iobase + PCL816_MUX); From ab3c44fa38b30b990fd1a29e5954b044488ff990 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:26 -0700 Subject: [PATCH 0391/1375] staging: comedi: pcl816: convert private data flags to bit-fields The 'irq_was_now_closed' member is actually a flag, devpriv->int816_mode will always be > 0 when it's used to set irq_was_now_closed in the cancel function. Convert the flags in the private data to bit-fields to save a bit of space. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 54d75a7f866e..36c8c05a2f11 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -116,15 +116,15 @@ struct pcl816_private { int next_dma_buf; /* which DMA buffer will be used next round */ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ - unsigned char ai_neverending; /* if=1, then we do neverending record (you must use cancel()) */ - int irq_blocked; /* 1=IRQ now uses any subdev */ - int irq_was_now_closed; /* when IRQ finish, there's stored int816_mode for last interrupt */ int int816_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */ int ai_act_scan; /* how many scans we finished */ unsigned int ai_act_chanlist[16]; /* MUX setting for actual AI operations */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int divisor1; unsigned int divisor2; + unsigned int irq_blocked:1; + unsigned int irq_was_now_closed:1; + unsigned int ai_neverending:1; }; /* @@ -601,7 +601,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, { struct pcl816_private *devpriv = dev->private; - if (devpriv->irq_blocked > 0) { + if (devpriv->irq_blocked) { switch (devpriv->int816_mode) { case INT_TYPE_AI1_DMA: case INT_TYPE_AI3_DMA: @@ -628,7 +628,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, /* Stop A/D */ outb(0, dev->iobase + PCL816_CONTROL); devpriv->irq_blocked = 0; - devpriv->irq_was_now_closed = devpriv->int816_mode; + devpriv->irq_was_now_closed = 1; devpriv->int816_mode = 0; /* s->busy = 0; */ break; From efd5b7b5d79010ae147e384185b8ac594d028850 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:27 -0700 Subject: [PATCH 0392/1375] staging: comedi: pcl816: kzalloc'ed memory does not need to be cleared The private data is kzalloc'ed in the (*attach). There is no need to initialize any of the members to 0. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 36c8c05a2f11..ee7aca1c067b 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -802,9 +802,6 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->irq = it->options[1]; } - devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */ - devpriv->int816_mode = 0; /* mode of irq */ - /* we need an IRQ to do DMA on channel 3 or 1 */ if (dev->irq && (it->options[2] == 3 || it->options[2] == 1)) { ret = request_dma(it->options[2], dev->board_name); From 94349cb9cb540ef3351b691a675821a220fda1d0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:28 -0700 Subject: [PATCH 0393/1375] staging: comedi: pcl816: rename 'irq_blocked' in private data This member in the private data is a flag that indicates that an analog input async command is currently running. Rename it to make this clear. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index ee7aca1c067b..ab0100304732 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -122,7 +122,7 @@ struct pcl816_private { unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int divisor1; unsigned int divisor2; - unsigned int irq_blocked:1; + unsigned int ai_cmd_running:1; unsigned int irq_was_now_closed:1; unsigned int ai_neverending:1; }; @@ -370,7 +370,7 @@ static irqreturn_t interrupt_pcl816(int irq, void *d) } outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ - if (!dev->irq || !devpriv->irq_blocked || !devpriv->int816_mode) { + if (!dev->irq || !devpriv->ai_cmd_running || !devpriv->int816_mode) { if (devpriv->irq_was_now_closed) { devpriv->irq_was_now_closed = 0; /* comedi_error(dev,"last IRQ.."); */ @@ -471,7 +471,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned int dma_flags, bytes, dmairq; unsigned int seglen; - if (devpriv->irq_blocked) + if (devpriv->ai_cmd_running) return -EBUSY; pcl816_start_pacer(dev, false); @@ -484,7 +484,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_act_scan = 0; s->async->cur_chan = 0; - devpriv->irq_blocked = 1; + devpriv->ai_cmd_running = 1; devpriv->ai_poll_ptr = 0; devpriv->irq_was_now_closed = 0; @@ -601,7 +601,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, { struct pcl816_private *devpriv = dev->private; - if (devpriv->irq_blocked) { + if (devpriv->ai_cmd_running) { switch (devpriv->int816_mode) { case INT_TYPE_AI1_DMA: case INT_TYPE_AI3_DMA: @@ -627,7 +627,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, /* Stop A/D */ outb(0, dev->iobase + PCL816_CONTROL); - devpriv->irq_blocked = 0; + devpriv->ai_cmd_running = 0; devpriv->irq_was_now_closed = 1; devpriv->int816_mode = 0; /* s->busy = 0; */ From bf6e48e87c6df4a0a409d0bb7017095aa8da1504 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:29 -0700 Subject: [PATCH 0394/1375] staging: comedi: pcl816: remove unnecessary 'dev->irq' check If the dev->irq is not valid the interrupt function will not be hooked up during the attach. Remove the unnecessary check. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index ab0100304732..4742bc8f3aa4 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -370,7 +370,7 @@ static irqreturn_t interrupt_pcl816(int irq, void *d) } outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ - if (!dev->irq || !devpriv->ai_cmd_running || !devpriv->int816_mode) { + if (!devpriv->ai_cmd_running || !devpriv->int816_mode) { if (devpriv->irq_was_now_closed) { devpriv->irq_was_now_closed = 0; /* comedi_error(dev,"last IRQ.."); */ From f51eb4f4b9c2021583f2243e75c6a46b5a018144 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:30 -0700 Subject: [PATCH 0395/1375] staging: comedi: pcl816: remove unnecessary function separation comments These comments are just added cruft. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 40 ------------------------- 1 file changed, 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 4742bc8f3aa4..aae2947281df 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -127,9 +127,6 @@ struct pcl816_private { unsigned int ai_neverending:1; }; -/* -============================================================================== -*/ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, unsigned int chanlen); @@ -216,11 +213,6 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, return n; } -/* -============================================================================== - analog input interrupt mode 1 & 3, 818 cards - one sample per interrupt version -*/ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) { struct comedi_device *dev = d; @@ -266,10 +258,6 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== - analog input dma mode 1 & 3, 816 cards -*/ static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subdevice *s, unsigned short *ptr, @@ -346,10 +334,6 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== - INT procedure -*/ static irqreturn_t interrupt_pcl816(int irq, void *d) { struct comedi_device *dev = d; @@ -383,9 +367,6 @@ static irqreturn_t interrupt_pcl816(int irq, void *d) return IRQ_NONE; } -/* -============================================================================== -*/ static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -592,10 +573,6 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) return s->async->buf_write_count - s->async->buf_read_count; } -/* -============================================================================== - cancel any mode 1-4 AI -*/ static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -637,10 +614,6 @@ static int pcl816_ai_cancel(struct comedi_device *dev, return 0; } -/* -============================================================================== - chech for PCL816 -*/ static int pcl816_check(unsigned long iobase) { outb(0x00, iobase + PCL816_MUX); @@ -660,10 +633,6 @@ static int pcl816_check(unsigned long iobase) return 0; /* ok, card exist */ } -/* -============================================================================== - reset whole PCL-816 cards -*/ static void pcl816_reset(struct comedi_device *dev) { unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE; @@ -686,11 +655,6 @@ static void pcl816_reset(struct comedi_device *dev) outb(0, dev->iobase + PCL816_RANGE); } -/* -============================================================================== - Check if channel list from user is built correctly - If it's ok, then return non-zero length of repeated segment of channel list -*/ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, @@ -747,10 +711,6 @@ check_channel_list(struct comedi_device *dev, return seglen; /* we can serve this with MUX logic */ } -/* -============================================================================== - Program scan/gain logic with channel list. -*/ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int *chanlist, From c36d44ace681cdbed05d06df736e772a80e20992 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Feb 2014 10:11:31 -0700 Subject: [PATCH 0396/1375] staging: comedi: pcl816: tidy up pcl818_check() This function probes a number of the boards registers during the (*attach) to verify that it is actually a PCL-816 compatible board. For aesthetics, move the function closer to the (*attach). To better match the pcl818 driver, allocate the private data before calling pcl816_check(). Refactor the function to return an errno if fails. Change the errno from -EIO to -ENODEV and remove the unnecessary dev_err() noise. Make sure the CONTROL register is reset to a known state after the check. The 0x18 value actually defines an invalid interrupt selection and sets an undefined bit. Add a couple comments to clarify the magic values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 58 +++++++++++++------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index aae2947281df..2e383ebde119 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -614,25 +614,6 @@ static int pcl816_ai_cancel(struct comedi_device *dev, return 0; } -static int pcl816_check(unsigned long iobase) -{ - outb(0x00, iobase + PCL816_MUX); - udelay(1); - if (inb(iobase + PCL816_MUX) != 0x00) - return 1; /* there isn't card */ - outb(0x55, iobase + PCL816_MUX); - udelay(1); - if (inb(iobase + PCL816_MUX) != 0x55) - return 1; /* there isn't card */ - outb(0x00, iobase + PCL816_MUX); - udelay(1); - outb(0x18, iobase + PCL816_CONTROL); - udelay(1); - if (inb(iobase + PCL816_CONTROL) != 0x18) - return 1; /* there isn't card */ - return 0; /* ok, card exist */ -} - static void pcl816_reset(struct comedi_device *dev) { unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE; @@ -733,6 +714,30 @@ setup_channel_list(struct comedi_device *dev, dev->iobase + PCL816_MUX); } +static int pcl816_check(struct comedi_device *dev) +{ + /* the MUX register should return the same value written */ + outb(0x00, dev->iobase + PCL816_MUX); + if (inb(dev->iobase + PCL816_MUX) != 0x00) + return -ENODEV; + outb(0x55, dev->iobase + PCL816_MUX); + if (inb(dev->iobase + PCL816_MUX) != 0x55) + return -ENODEV; + + /* reset the MUX register to a known state */ + outb(0x00, dev->iobase + PCL816_MUX); + + /* the CONTROL register should return the same value written */ + outb(0x18, dev->iobase + PCL816_CONTROL); + if (inb(dev->iobase + PCL816_CONTROL) != 0x18) + return -ENODEV; + + /* reset the CONTROL register to a known state */ + outb(0x00, dev->iobase + PCL816_CONTROL); + + return 0; +} + static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct pcl816_board *board = comedi_board(dev); @@ -741,18 +746,17 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) int ret; int i; + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + ret = comedi_request_region(dev, it->options[0], 0x10); if (ret) return ret; - if (pcl816_check(dev->iobase)) { - dev_err(dev->class_dev, "I can't detect board. FAIL!\n"); - return -EIO; - } - - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; + ret = pcl816_check(dev); + if (ret) + return ret; /* we can use IRQ 2-7 for async command support */ if (it->options[1] >= 2 && it->options[1] <= 7) { From 39a3a0138f6113805dc9e0813214cd4b03bd8ac0 Mon Sep 17 00:00:00 2001 From: Archana Patni Date: Thu, 20 Feb 2014 06:29:00 +0000 Subject: [PATCH 0397/1375] iio: hid-sensors: Added Proximity Sensor Driver Added usage id processing for Proximity (Human Presence). This uses IIO interfaces for triggered buffer to present data to user mode. This uses HID sensor framework for registering callback events from the sensor hub. Signed-off-by: Archana Patni Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 14 ++ drivers/iio/light/Makefile | 1 + drivers/iio/light/hid-sensor-prox.c | 375 ++++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 5 + 4 files changed, 395 insertions(+) create mode 100644 drivers/iio/light/hid-sensor-prox.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 3a7a5d9f03a3..c89740d4748f 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -73,6 +73,20 @@ config HID_SENSOR_ALS Say yes here to build support for the HID SENSOR Ambient light sensor. +config HID_SENSOR_PROX + depends on HID_SENSOR_HUB + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select HID_SENSOR_IIO_COMMON + select HID_SENSOR_IIO_TRIGGER + tristate "HID PROX" + help + Say yes here to build support for the HID SENSOR + Proximity sensor. + + To compile this driver as a module, choose M here: the + module will be called hid-sensor-prox. + config SENSORS_LM3533 tristate "LM3533 ambient light sensor" depends on MFD_LM3533 diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 924530597f83..3eb36e5151fa 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_CM32181) += cm32181.o obj-$(CONFIG_CM36651) += cm36651.o obj-$(CONFIG_GP2AP020A00F) += gp2ap020a00f.o obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o +obj-$(CONFIG_HID_SENSOR_PROX) += hid-sensor-prox.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_LTR501) += ltr501.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c new file mode 100644 index 000000000000..1894ab196f97 --- /dev/null +++ b/drivers/iio/light/hid-sensor-prox.c @@ -0,0 +1,375 @@ +/* + * HID Sensors Driver + * Copyright (c) 2014, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../common/hid-sensors/hid-sensor-trigger.h" + +#define CHANNEL_SCAN_INDEX_PRESENCE 0 + +struct prox_state { + struct hid_sensor_hub_callbacks callbacks; + struct hid_sensor_common common_attributes; + struct hid_sensor_hub_attribute_info prox_attr; + u32 human_presence; +}; + +/* Channel definitions */ +static const struct iio_chan_spec prox_channels[] = { + { + .type = IIO_PROXIMITY, + .modified = 1, + .channel2 = IIO_NO_MOD, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS), + .scan_index = CHANNEL_SCAN_INDEX_PRESENCE, + } +}; + +/* Adjust channel real bits based on report descriptor */ +static void prox_adjust_channel_bit_mask(struct iio_chan_spec *channels, + int channel, int size) +{ + channels[channel].scan_type.sign = 's'; + /* Real storage bits will change based on the report desc. */ + channels[channel].scan_type.realbits = size * 8; + /* Maximum size of a sample to capture is u32 */ + channels[channel].scan_type.storagebits = sizeof(u32) * 8; +} + +/* Channel read_raw handler */ +static int prox_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) +{ + struct prox_state *prox_state = iio_priv(indio_dev); + int report_id = -1; + u32 address; + int ret; + int ret_type; + + *val = 0; + *val2 = 0; + switch (mask) { + case IIO_CHAN_INFO_RAW: + switch (chan->scan_index) { + case CHANNEL_SCAN_INDEX_PRESENCE: + report_id = prox_state->prox_attr.report_id; + address = + HID_USAGE_SENSOR_HUMAN_PRESENCE; + break; + default: + report_id = -1; + break; + } + if (report_id >= 0) + *val = sensor_hub_input_attr_get_raw_value( + prox_state->common_attributes.hsdev, + HID_USAGE_SENSOR_PROX, address, + report_id); + else { + *val = 0; + return -EINVAL; + } + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SCALE: + *val = prox_state->prox_attr.units; + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_OFFSET: + *val = hid_sensor_convert_exponent( + prox_state->prox_attr.unit_expo); + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SAMP_FREQ: + ret = hid_sensor_read_samp_freq_value( + &prox_state->common_attributes, val, val2); + ret_type = IIO_VAL_INT_PLUS_MICRO; + break; + case IIO_CHAN_INFO_HYSTERESIS: + ret = hid_sensor_read_raw_hyst_value( + &prox_state->common_attributes, val, val2); + ret_type = IIO_VAL_INT_PLUS_MICRO; + break; + default: + ret_type = -EINVAL; + break; + } + + return ret_type; +} + +/* Channel write_raw handler */ +static int prox_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct prox_state *prox_state = iio_priv(indio_dev); + int ret = 0; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + ret = hid_sensor_write_samp_freq_value( + &prox_state->common_attributes, val, val2); + break; + case IIO_CHAN_INFO_HYSTERESIS: + ret = hid_sensor_write_raw_hyst_value( + &prox_state->common_attributes, val, val2); + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static const struct iio_info prox_info = { + .driver_module = THIS_MODULE, + .read_raw = &prox_read_raw, + .write_raw = &prox_write_raw, +}; + +/* Function to push data to buffer */ +static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data, + int len) +{ + dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); + iio_push_to_buffers(indio_dev, data); +} + +/* Callback handler to send event after all samples are received and captured */ +static int prox_proc_event(struct hid_sensor_hub_device *hsdev, + unsigned usage_id, + void *priv) +{ + struct iio_dev *indio_dev = platform_get_drvdata(priv); + struct prox_state *prox_state = iio_priv(indio_dev); + + dev_dbg(&indio_dev->dev, "prox_proc_event [%d]\n", + prox_state->common_attributes.data_ready); + if (prox_state->common_attributes.data_ready) + hid_sensor_push_data(indio_dev, + &prox_state->human_presence, + sizeof(prox_state->human_presence)); + + return 0; +} + +/* Capture samples in local storage */ +static int prox_capture_sample(struct hid_sensor_hub_device *hsdev, + unsigned usage_id, + size_t raw_len, char *raw_data, + void *priv) +{ + struct iio_dev *indio_dev = platform_get_drvdata(priv); + struct prox_state *prox_state = iio_priv(indio_dev); + int ret = -EINVAL; + + switch (usage_id) { + case HID_USAGE_SENSOR_HUMAN_PRESENCE: + prox_state->human_presence = *(u32 *)raw_data; + ret = 0; + break; + default: + break; + } + + return ret; +} + +/* Parse report which is specific to an usage id*/ +static int prox_parse_report(struct platform_device *pdev, + struct hid_sensor_hub_device *hsdev, + struct iio_chan_spec *channels, + unsigned usage_id, + struct prox_state *st) +{ + int ret; + + ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, + usage_id, + HID_USAGE_SENSOR_HUMAN_PRESENCE, + &st->prox_attr); + if (ret < 0) + return ret; + prox_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESENCE, + st->prox_attr.size); + + dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index, + st->prox_attr.report_id); + + /* Set Sensitivity field ids, when there is no individual modifier */ + if (st->common_attributes.sensitivity.index < 0) { + sensor_hub_input_get_attribute_info(hsdev, + HID_FEATURE_REPORT, usage_id, + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | + HID_USAGE_SENSOR_DATA_PRESENCE, + &st->common_attributes.sensitivity); + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + } + return ret; +} + +/* Function to initialize the processing for usage id */ +static int hid_prox_probe(struct platform_device *pdev) +{ + int ret = 0; + static const char *name = "prox"; + struct iio_dev *indio_dev; + struct prox_state *prox_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 prox_state)); + if (!indio_dev) + return -ENOMEM; + platform_set_drvdata(pdev, indio_dev); + + prox_state = iio_priv(indio_dev); + prox_state->common_attributes.hsdev = hsdev; + prox_state->common_attributes.pdev = pdev; + + ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_PROX, + &prox_state->common_attributes); + if (ret) { + dev_err(&pdev->dev, "failed to setup common attributes\n"); + return ret; + } + + channels = kmemdup(prox_channels, sizeof(prox_channels), GFP_KERNEL); + if (!channels) { + dev_err(&pdev->dev, "failed to duplicate channels\n"); + return -ENOMEM; + } + + ret = prox_parse_report(pdev, hsdev, channels, + HID_USAGE_SENSOR_PROX, prox_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(prox_channels); + indio_dev->dev.parent = &pdev->dev; + indio_dev->info = &prox_info; + indio_dev->name = name; + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, + NULL, NULL); + if (ret) { + dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); + goto error_free_dev_mem; + } + prox_state->common_attributes.data_ready = false; + ret = hid_sensor_setup_trigger(indio_dev, name, + &prox_state->common_attributes); + if (ret) { + dev_err(&pdev->dev, "trigger setup failed\n"); + goto error_unreg_buffer_funcs; + } + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(&pdev->dev, "device register failed\n"); + goto error_remove_trigger; + } + + prox_state->callbacks.send_event = prox_proc_event; + prox_state->callbacks.capture_sample = prox_capture_sample; + prox_state->callbacks.pdev = pdev; + ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_PROX, + &prox_state->callbacks); + if (ret < 0) { + dev_err(&pdev->dev, "callback reg failed\n"); + goto error_iio_unreg; + } + + return ret; + +error_iio_unreg: + iio_device_unregister(indio_dev); +error_remove_trigger: + hid_sensor_remove_trigger(&prox_state->common_attributes); +error_unreg_buffer_funcs: + iio_triggered_buffer_cleanup(indio_dev); +error_free_dev_mem: + kfree(indio_dev->channels); + return ret; +} + +/* Function to deinitialize the processing for usage id */ +static int hid_prox_remove(struct platform_device *pdev) +{ + struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct prox_state *prox_state = iio_priv(indio_dev); + + sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PROX); + iio_device_unregister(indio_dev); + hid_sensor_remove_trigger(&prox_state->common_attributes); + iio_triggered_buffer_cleanup(indio_dev); + kfree(indio_dev->channels); + + return 0; +} + +static struct platform_device_id hid_prox_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-200011", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_prox_ids); + +static struct platform_driver hid_prox_platform_driver = { + .id_table = hid_prox_ids, + .driver = { + .name = KBUILD_MODNAME, + .owner = THIS_MODULE, + }, + .probe = hid_prox_probe, + .remove = hid_prox_remove, +}; +module_platform_driver(hid_prox_platform_driver); + +MODULE_DESCRIPTION("HID Sensor Proximity"); +MODULE_AUTHOR("Archana Patni "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index beaf965621c1..9bc9e35f1b3f 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -33,6 +33,11 @@ #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0 #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1 +/* PROX (200011) */ +#define HID_USAGE_SENSOR_PROX 0x200011 +#define HID_USAGE_SENSOR_DATA_PRESENCE 0x2004b0 +#define HID_USAGE_SENSOR_HUMAN_PRESENCE 0x2004b1 + /* Gyro 3D: (200076) */ #define HID_USAGE_SENSOR_GYRO_3D 0x200076 #define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY 0x200456 From f64a799b8a49e3e26497b26ea78af01fc6302874 Mon Sep 17 00:00:00 2001 From: Archana Patni Date: Thu, 20 Feb 2014 06:30:00 +0000 Subject: [PATCH 0398/1375] iio: hid-sensors: Added Pressure Sensor driver Added usage id processing for Pressure Sensor. This uses IIO interfaces for triggered buffer to present data to user mode. This uses HID sensor framework for registering callback events from the sensor hub. Signed-off-by: Archana Patni Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 14 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/hid-sensor-press.c | 376 ++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 5 + 4 files changed, 396 insertions(+) create mode 100644 drivers/iio/pressure/hid-sensor-press.c diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index a8b9cae5c173..6215761b3c53 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -5,6 +5,20 @@ menu "Pressure sensors" +config HID_SENSOR_PRESS + depends on HID_SENSOR_HUB + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select HID_SENSOR_IIO_COMMON + select HID_SENSOR_IIO_TRIGGER + tristate "HID PRESS" + help + Say yes here to build support for the HID SENSOR + Pressure driver + + To compile this driver as a module, choose M here: the module + will be called hid-sensor-press. + config MPL3115 tristate "Freescale MPL3115A2 pressure sensor driver" depends on I2C diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 42bb9fcf5436..4a57bf65b04b 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -3,6 +3,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o obj-$(CONFIG_MPL3115) += mpl3115.o obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o st_pressure-y := st_pressure_core.o diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c new file mode 100644 index 000000000000..e0e6409aa94e --- /dev/null +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -0,0 +1,376 @@ +/* + * HID Sensors Driver + * Copyright (c) 2014, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../common/hid-sensors/hid-sensor-trigger.h" + +#define CHANNEL_SCAN_INDEX_PRESSURE 0 + +struct press_state { + struct hid_sensor_hub_callbacks callbacks; + struct hid_sensor_common common_attributes; + struct hid_sensor_hub_attribute_info press_attr; + u32 press_data; +}; + +/* Channel definitions */ +static const struct iio_chan_spec press_channels[] = { + { + .type = IIO_PRESSURE, + .modified = 1, + .channel2 = IIO_NO_MOD, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS), + .scan_index = CHANNEL_SCAN_INDEX_PRESSURE, + } +}; + +/* Adjust channel real bits based on report descriptor */ +static void press_adjust_channel_bit_mask(struct iio_chan_spec *channels, + int channel, int size) +{ + channels[channel].scan_type.sign = 's'; + /* Real storage bits will change based on the report desc. */ + channels[channel].scan_type.realbits = size * 8; + /* Maximum size of a sample to capture is u32 */ + channels[channel].scan_type.storagebits = sizeof(u32) * 8; +} + +/* Channel read_raw handler */ +static int press_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, + long mask) +{ + struct press_state *press_state = iio_priv(indio_dev); + int report_id = -1; + u32 address; + int ret; + int ret_type; + + *val = 0; + *val2 = 0; + switch (mask) { + case IIO_CHAN_INFO_RAW: + switch (chan->scan_index) { + case CHANNEL_SCAN_INDEX_PRESSURE: + report_id = press_state->press_attr.report_id; + address = + HID_USAGE_SENSOR_ATMOSPHERIC_PRESSURE; + break; + default: + report_id = -1; + break; + } + if (report_id >= 0) + *val = sensor_hub_input_attr_get_raw_value( + press_state->common_attributes.hsdev, + HID_USAGE_SENSOR_PRESSURE, address, + report_id); + else { + *val = 0; + return -EINVAL; + } + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SCALE: + *val = press_state->press_attr.units; + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_OFFSET: + *val = hid_sensor_convert_exponent( + press_state->press_attr.unit_expo); + ret_type = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SAMP_FREQ: + ret = hid_sensor_read_samp_freq_value( + &press_state->common_attributes, val, val2); + ret_type = IIO_VAL_INT_PLUS_MICRO; + break; + case IIO_CHAN_INFO_HYSTERESIS: + ret = hid_sensor_read_raw_hyst_value( + &press_state->common_attributes, val, val2); + ret_type = IIO_VAL_INT_PLUS_MICRO; + break; + default: + ret_type = -EINVAL; + break; + } + + return ret_type; +} + +/* Channel write_raw handler */ +static int press_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct press_state *press_state = iio_priv(indio_dev); + int ret = 0; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + ret = hid_sensor_write_samp_freq_value( + &press_state->common_attributes, val, val2); + break; + case IIO_CHAN_INFO_HYSTERESIS: + ret = hid_sensor_write_raw_hyst_value( + &press_state->common_attributes, val, val2); + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static const struct iio_info press_info = { + .driver_module = THIS_MODULE, + .read_raw = &press_read_raw, + .write_raw = &press_write_raw, +}; + +/* Function to push data to buffer */ +static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data, + int len) +{ + dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); + iio_push_to_buffers(indio_dev, data); +} + +/* Callback handler to send event after all samples are received and captured */ +static int press_proc_event(struct hid_sensor_hub_device *hsdev, + unsigned usage_id, + void *priv) +{ + struct iio_dev *indio_dev = platform_get_drvdata(priv); + struct press_state *press_state = iio_priv(indio_dev); + + dev_dbg(&indio_dev->dev, "press_proc_event [%d]\n", + press_state->common_attributes.data_ready); + if (press_state->common_attributes.data_ready) + hid_sensor_push_data(indio_dev, + &press_state->press_data, + sizeof(press_state->press_data)); + + return 0; +} + +/* Capture samples in local storage */ +static int press_capture_sample(struct hid_sensor_hub_device *hsdev, + unsigned usage_id, + size_t raw_len, char *raw_data, + void *priv) +{ + struct iio_dev *indio_dev = platform_get_drvdata(priv); + struct press_state *press_state = iio_priv(indio_dev); + int ret = -EINVAL; + + switch (usage_id) { + case HID_USAGE_SENSOR_ATMOSPHERIC_PRESSURE: + press_state->press_data = *(u32 *)raw_data; + ret = 0; + break; + default: + break; + } + + return ret; +} + +/* Parse report which is specific to an usage id*/ +static int press_parse_report(struct platform_device *pdev, + struct hid_sensor_hub_device *hsdev, + struct iio_chan_spec *channels, + unsigned usage_id, + struct press_state *st) +{ + int ret; + + ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, + usage_id, + HID_USAGE_SENSOR_ATMOSPHERIC_PRESSURE, + &st->press_attr); + if (ret < 0) + return ret; + press_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE, + st->press_attr.size); + + dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index, + st->press_attr.report_id); + + /* Set Sensitivity field ids, when there is no individual modifier */ + if (st->common_attributes.sensitivity.index < 0) { + sensor_hub_input_get_attribute_info(hsdev, + HID_FEATURE_REPORT, usage_id, + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | + HID_USAGE_SENSOR_DATA_ATMOSPHERIC_PRESSURE, + &st->common_attributes.sensitivity); + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + } + return ret; +} + +/* Function to initialize the processing for usage id */ +static int hid_press_probe(struct platform_device *pdev) +{ + int ret = 0; + static const char *name = "press"; + 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)); + if (!indio_dev) + return -ENOMEM; + platform_set_drvdata(pdev, indio_dev); + + press_state = iio_priv(indio_dev); + press_state->common_attributes.hsdev = hsdev; + press_state->common_attributes.pdev = pdev; + + ret = hid_sensor_parse_common_attributes(hsdev, + HID_USAGE_SENSOR_PRESSURE, + &press_state->common_attributes); + if (ret) { + dev_err(&pdev->dev, "failed to setup common attributes\n"); + return ret; + } + + channels = kmemdup(press_channels, sizeof(press_channels), GFP_KERNEL); + if (!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); + 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; + indio_dev->info = &press_info; + indio_dev->name = name; + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, + NULL, NULL); + if (ret) { + dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); + goto error_free_dev_mem; + } + press_state->common_attributes.data_ready = false; + ret = hid_sensor_setup_trigger(indio_dev, name, + &press_state->common_attributes); + if (ret) { + dev_err(&pdev->dev, "trigger setup failed\n"); + goto error_unreg_buffer_funcs; + } + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(&pdev->dev, "device register failed\n"); + goto error_remove_trigger; + } + + press_state->callbacks.send_event = press_proc_event; + press_state->callbacks.capture_sample = press_capture_sample; + press_state->callbacks.pdev = pdev; + ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_PRESSURE, + &press_state->callbacks); + if (ret < 0) { + dev_err(&pdev->dev, "callback reg failed\n"); + goto error_iio_unreg; + } + + return ret; + +error_iio_unreg: + iio_device_unregister(indio_dev); +error_remove_trigger: + hid_sensor_remove_trigger(&press_state->common_attributes); +error_unreg_buffer_funcs: + iio_triggered_buffer_cleanup(indio_dev); +error_free_dev_mem: + kfree(indio_dev->channels); + return ret; +} + +/* Function to deinitialize the processing for usage id */ +static int hid_press_remove(struct platform_device *pdev) +{ + struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct press_state *press_state = iio_priv(indio_dev); + + sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PRESSURE); + iio_device_unregister(indio_dev); + hid_sensor_remove_trigger(&press_state->common_attributes); + iio_triggered_buffer_cleanup(indio_dev); + kfree(indio_dev->channels); + + return 0; +} + +static struct platform_device_id hid_press_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-200031", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_press_ids); + +static struct platform_driver hid_press_platform_driver = { + .id_table = hid_press_ids, + .driver = { + .name = KBUILD_MODNAME, + .owner = THIS_MODULE, + }, + .probe = hid_press_probe, + .remove = hid_press_remove, +}; +module_platform_driver(hid_press_platform_driver); + +MODULE_DESCRIPTION("HID Sensor Pressure"); +MODULE_AUTHOR("Archana Patni "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index 9bc9e35f1b3f..537161a997ab 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -38,6 +38,11 @@ #define HID_USAGE_SENSOR_DATA_PRESENCE 0x2004b0 #define HID_USAGE_SENSOR_HUMAN_PRESENCE 0x2004b1 +/* Pressure (200031) */ +#define HID_USAGE_SENSOR_PRESSURE 0x200031 +#define HID_USAGE_SENSOR_DATA_ATMOSPHERIC_PRESSURE 0x200430 +#define HID_USAGE_SENSOR_ATMOSPHERIC_PRESSURE 0x200431 + /* Gyro 3D: (200076) */ #define HID_USAGE_SENSOR_GYRO_3D 0x200076 #define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY 0x200456 From 931878405b869093c90d57a0a34f0c2b3641c4ea Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Thu, 20 Feb 2014 17:49:00 +0000 Subject: [PATCH 0399/1375] iio:pressure: Add support for LPS25H pressure sensor This patch adds support for the new barometer sensor: LPS25H. Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 2 +- drivers/iio/pressure/st_pressure.h | 1 + drivers/iio/pressure/st_pressure_core.c | 87 +++++++++++++++++++++++-- drivers/iio/pressure/st_pressure_i2c.c | 1 + drivers/iio/pressure/st_pressure_spi.c | 1 + 5 files changed, 84 insertions(+), 8 deletions(-) diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 6215761b3c53..d88ff17fedb2 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -40,7 +40,7 @@ config IIO_ST_PRESS select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) help Say yes here to build support for STMicroelectronics pressure - sensors: LPS001WP, LPS331AP. + sensors: LPS001WP, LPS25H, LPS331AP. This driver can also be built as a module. If so, these modules will be created: diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index 049c21acf1f0..242943c0c4e4 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -15,6 +15,7 @@ #include #define LPS001WP_PRESS_DEV_NAME "lps001wp" +#define LPS25H_PRESS_DEV_NAME "lps25h" #define LPS331AP_PRESS_DEV_NAME "lps331ap" /** diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 58083f9d51c5..7418768ed49c 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -40,6 +40,9 @@ /* FULLSCALE */ #define ST_PRESS_FS_AVL_1260MB 1260 +#define ST_PRESS_1_OUT_XL_ADDR 0x28 +#define ST_TEMP_1_OUT_L_ADDR 0x2b + /* CUSTOM VALUES FOR LPS331AP SENSOR */ #define ST_PRESS_LPS331AP_WAI_EXP 0xbb #define ST_PRESS_LPS331AP_ODR_ADDR 0x20 @@ -62,8 +65,6 @@ #define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20 #define ST_PRESS_LPS331AP_MULTIREAD_BIT true #define ST_PRESS_LPS331AP_TEMP_OFFSET 42500 -#define ST_PRESS_LPS331AP_OUT_XL_ADDR 0x28 -#define ST_TEMP_LPS331AP_OUT_L_ADDR 0x2b /* CUSTOM VALUES FOR LPS001WP SENSOR */ #define ST_PRESS_LPS001WP_WAI_EXP 0xba @@ -80,11 +81,36 @@ #define ST_PRESS_LPS001WP_OUT_L_ADDR 0x28 #define ST_TEMP_LPS001WP_OUT_L_ADDR 0x2a -static const struct iio_chan_spec st_press_lps331ap_channels[] = { +/* CUSTOM VALUES FOR LPS25H SENSOR */ +#define ST_PRESS_LPS25H_WAI_EXP 0xbd +#define ST_PRESS_LPS25H_ODR_ADDR 0x20 +#define ST_PRESS_LPS25H_ODR_MASK 0x70 +#define ST_PRESS_LPS25H_ODR_AVL_1HZ_VAL 0x01 +#define ST_PRESS_LPS25H_ODR_AVL_7HZ_VAL 0x02 +#define ST_PRESS_LPS25H_ODR_AVL_13HZ_VAL 0x03 +#define ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL 0x04 +#define ST_PRESS_LPS25H_PW_ADDR 0x20 +#define ST_PRESS_LPS25H_PW_MASK 0x80 +#define ST_PRESS_LPS25H_FS_ADDR 0x00 +#define ST_PRESS_LPS25H_FS_MASK 0x00 +#define ST_PRESS_LPS25H_FS_AVL_1260_VAL 0x00 +#define ST_PRESS_LPS25H_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE +#define ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE +#define ST_PRESS_LPS25H_BDU_ADDR 0x20 +#define ST_PRESS_LPS25H_BDU_MASK 0x04 +#define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23 +#define ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK 0x01 +#define ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK 0x10 +#define ST_PRESS_LPS25H_MULTIREAD_BIT true +#define ST_PRESS_LPS25H_TEMP_OFFSET 42500 +#define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28 +#define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b + +static const struct iio_chan_spec st_press_1_channels[] = { { .type = IIO_PRESSURE, .channel2 = IIO_NO_MOD, - .address = ST_PRESS_LPS331AP_OUT_XL_ADDR, + .address = ST_PRESS_1_OUT_XL_ADDR, .scan_index = ST_SENSORS_SCAN_X, .scan_type = { .sign = 'u', @@ -99,7 +125,7 @@ static const struct iio_chan_spec st_press_lps331ap_channels[] = { { .type = IIO_TEMP, .channel2 = IIO_NO_MOD, - .address = ST_TEMP_LPS331AP_OUT_L_ADDR, + .address = ST_TEMP_1_OUT_L_ADDR, .scan_index = -1, .scan_type = { .sign = 'u', @@ -156,8 +182,8 @@ static const struct st_sensors st_press_sensors[] = { .sensors_supported = { [0] = LPS331AP_PRESS_DEV_NAME, }, - .ch = (struct iio_chan_spec *)st_press_lps331ap_channels, - .num_ch = ARRAY_SIZE(st_press_lps331ap_channels), + .ch = (struct iio_chan_spec *)st_press_1_channels, + .num_ch = ARRAY_SIZE(st_press_1_channels), .odr = { .addr = ST_PRESS_LPS331AP_ODR_ADDR, .mask = ST_PRESS_LPS331AP_ODR_MASK, @@ -233,6 +259,53 @@ static const struct st_sensors st_press_sensors[] = { .multi_read_bit = ST_PRESS_LPS001WP_MULTIREAD_BIT, .bootime = 2, }, + { + .wai = ST_PRESS_LPS25H_WAI_EXP, + .sensors_supported = { + [0] = LPS25H_PRESS_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_press_1_channels, + .num_ch = ARRAY_SIZE(st_press_1_channels), + .odr = { + .addr = ST_PRESS_LPS25H_ODR_ADDR, + .mask = ST_PRESS_LPS25H_ODR_MASK, + .odr_avl = { + { 1, ST_PRESS_LPS25H_ODR_AVL_1HZ_VAL, }, + { 7, ST_PRESS_LPS25H_ODR_AVL_7HZ_VAL, }, + { 13, ST_PRESS_LPS25H_ODR_AVL_13HZ_VAL, }, + { 25, ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL, }, + }, + }, + .pw = { + .addr = ST_PRESS_LPS25H_PW_ADDR, + .mask = ST_PRESS_LPS25H_PW_MASK, + .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .fs = { + .addr = ST_PRESS_LPS25H_FS_ADDR, + .mask = ST_PRESS_LPS25H_FS_MASK, + .fs_avl = { + [0] = { + .num = ST_PRESS_FS_AVL_1260MB, + .value = ST_PRESS_LPS25H_FS_AVL_1260_VAL, + .gain = ST_PRESS_LPS25H_FS_AVL_1260_GAIN, + .gain2 = ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN, + }, + }, + }, + .bdu = { + .addr = ST_PRESS_LPS25H_BDU_ADDR, + .mask = ST_PRESS_LPS25H_BDU_MASK, + }, + .drdy_irq = { + .addr = ST_PRESS_LPS25H_DRDY_IRQ_ADDR, + .mask_int1 = ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK, + }, + .multi_read_bit = ST_PRESS_LPS25H_MULTIREAD_BIT, + .bootime = 2, + }, }; static int st_press_read_raw(struct iio_dev *indio_dev, diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 51eab7fcb194..3cd73e39b840 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -50,6 +50,7 @@ static int st_press_i2c_remove(struct i2c_client *client) static const struct i2c_device_id st_press_id_table[] = { { LPS001WP_PRESS_DEV_NAME }, + { LPS25H_PRESS_DEV_NAME }, { LPS331AP_PRESS_DEV_NAME }, {}, }; diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 27322af6d665..f45d430ec529 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -49,6 +49,7 @@ static int st_press_spi_remove(struct spi_device *spi) static const struct spi_device_id st_press_id_table[] = { { LPS001WP_PRESS_DEV_NAME }, + { LPS25H_PRESS_DEV_NAME }, { LPS331AP_PRESS_DEV_NAME }, {}, }; From b91accafbb1031b80d22ad83576877ff2f8b4774 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 14 Feb 2014 18:49:00 +0000 Subject: [PATCH 0400/1375] iio:event: Fix and cleanup locking The event code currently holds a spinlock with IRQs disabled while calling kfifo_to_user(). kfifo_to_user() can generate a page fault though, which means we have to be able to sleep, which is not possible if the interrupts are disabled. The good thing is that kfifo handles concurrent read and write access just fine as long as there is only one reader and one writer, so we do not any locking to protect against concurrent access from the read and writer thread. It is possible though that userspace is trying to read from the event FIFO from multiple concurrent threads, so we need to add locking to protect against this. This is done using a mutex. The mutex will only protect the kfifo_to_user() call, it will not protect the waitqueue. This means that multiple threads can be waiting for new data and once a new event is added to the FIFO all waiting threads will be woken up. If one of those threads is unable to read any data (because another thread already read all the data) it will go back to sleep. The only remaining issue is that now that the clearing of the BUSY flag and the emptying of the FIFO does no longer happen in one atomic step it is possible that a event is added to the FIFO after it has been emptied and this sample will be visible the next time a new event file descriptor is created. To avoid this rather move the emptying of the FIFO from iio_event_chrdev_release to iio_event_getfd(). Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-event.c | 83 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 2e6f8e026fab..ea6e06b9c7d4 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -40,6 +40,7 @@ struct iio_event_interface { struct list_head dev_attr_list; unsigned long flags; struct attribute_group group; + struct mutex read_lock; }; /** @@ -47,16 +48,17 @@ struct iio_event_interface { * @indio_dev: IIO device structure * @ev_code: What event * @timestamp: When the event occurred + * + * Note: The caller must make sure that this function is not running + * concurrently for the same indio_dev more than once. **/ int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) { struct iio_event_interface *ev_int = indio_dev->event_interface; struct iio_event_data ev; - unsigned long flags; int copied; /* Does anyone care? */ - spin_lock_irqsave(&ev_int->wait.lock, flags); if (test_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { ev.id = ev_code; @@ -64,9 +66,8 @@ int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) copied = kfifo_put(&ev_int->det_events, ev); if (copied != 0) - wake_up_locked_poll(&ev_int->wait, POLLIN); + wake_up_poll(&ev_int->wait, POLLIN); } - spin_unlock_irqrestore(&ev_int->wait.lock, flags); return 0; } @@ -87,10 +88,8 @@ static unsigned int iio_event_poll(struct file *filep, poll_wait(filep, &ev_int->wait, wait); - spin_lock_irq(&ev_int->wait.lock); if (!kfifo_is_empty(&ev_int->det_events)) events = POLLIN | POLLRDNORM; - spin_unlock_irq(&ev_int->wait.lock); return events; } @@ -111,31 +110,40 @@ static ssize_t iio_event_chrdev_read(struct file *filep, if (count < sizeof(struct iio_event_data)) return -EINVAL; - spin_lock_irq(&ev_int->wait.lock); - if (kfifo_is_empty(&ev_int->det_events)) { - if (filep->f_flags & O_NONBLOCK) { - ret = -EAGAIN; - goto error_unlock; - } - /* Blocking on device; waiting for something to be there */ - ret = wait_event_interruptible_locked_irq(ev_int->wait, + do { + if (kfifo_is_empty(&ev_int->det_events)) { + if (filep->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible(ev_int->wait, !kfifo_is_empty(&ev_int->det_events) || indio_dev->info == NULL); - if (ret) - goto error_unlock; - if (indio_dev->info == NULL) { - ret = -ENODEV; - goto error_unlock; + if (ret) + return ret; + if (indio_dev->info == NULL) + return -ENODEV; } - /* Single access device so no one else can get the data */ - } - ret = kfifo_to_user(&ev_int->det_events, buf, count, &copied); + if (mutex_lock_interruptible(&ev_int->read_lock)) + return -ERESTARTSYS; + ret = kfifo_to_user(&ev_int->det_events, buf, count, &copied); + mutex_unlock(&ev_int->read_lock); -error_unlock: - spin_unlock_irq(&ev_int->wait.lock); + if (ret) + return ret; - return ret ? ret : copied; + /* + * If we couldn't read anything from the fifo (a different + * thread might have been faster) we either return -EAGAIN if + * the file descriptor is non-blocking, otherwise we go back to + * sleep and wait for more data to arrive. + */ + if (copied == 0 && (filep->f_flags & O_NONBLOCK)) + return -EAGAIN; + + } while (copied == 0); + + return copied; } static int iio_event_chrdev_release(struct inode *inode, struct file *filep) @@ -143,15 +151,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) struct iio_dev *indio_dev = filep->private_data; struct iio_event_interface *ev_int = indio_dev->event_interface; - spin_lock_irq(&ev_int->wait.lock); - __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); - /* - * In order to maintain a clean state for reopening, - * clear out any awaiting events. The mask will prevent - * any new __iio_push_event calls running. - */ - kfifo_reset_out(&ev_int->det_events); - spin_unlock_irq(&ev_int->wait.lock); + clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); iio_device_put(indio_dev); @@ -174,22 +174,20 @@ int iio_event_getfd(struct iio_dev *indio_dev) if (ev_int == NULL) return -ENODEV; - spin_lock_irq(&ev_int->wait.lock); - if (__test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { - spin_unlock_irq(&ev_int->wait.lock); + if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) return -EBUSY; - } - spin_unlock_irq(&ev_int->wait.lock); + iio_device_get(indio_dev); fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops, indio_dev, O_RDONLY | O_CLOEXEC); if (fd < 0) { - spin_lock_irq(&ev_int->wait.lock); - __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); - spin_unlock_irq(&ev_int->wait.lock); + clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); iio_device_put(indio_dev); + } else { + kfifo_reset_out(&ev_int->det_events); } + return fd; } @@ -424,6 +422,7 @@ static void iio_setup_ev_int(struct iio_event_interface *ev_int) { INIT_KFIFO(ev_int->det_events); init_waitqueue_head(&ev_int->wait); + mutex_init(&ev_int->read_lock); } static const char *iio_event_group_name = "events"; From 3e46f15211fc92812555dac5af765f88b0bfafbd Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 4 Nov 2013 11:24:00 +0000 Subject: [PATCH 0401/1375] imx-drm: imx-hdmi: convert HDMI clock settings to tabular form Rather than having large if() and switch() statements, provide a table to look up the register settings for various clock rates. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 250 +++++++++++------------------ 1 file changed, 95 insertions(+), 155 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 62ce0e86f14b..cb316bf3ec56 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -806,19 +806,94 @@ static void imx_hdmi_phy_sel_interface_control(struct imx_hdmi *hdmi, u8 enable) HDMI_PHY_CONF0_SELDIPIF_MASK); } +enum { + RES_8, + RES_10, + RES_12, + RES_MAX, +}; + +struct mpll_config { + unsigned long mpixelclock; + struct { + u16 cpce; + u16 gmp; + } res[RES_MAX]; +}; + +static const struct mpll_config mpll_config[] = { + { + 45250000, { + { 0x01e0, 0x0000 }, + { 0x21e1, 0x0000 }, + { 0x41e2, 0x0000 } + }, + }, { + 92500000, { + { 0x0140, 0x0005 }, + { 0x2141, 0x0005 }, + { 0x4142, 0x0005 }, + }, + }, { + 148500000, { + { 0x00a0, 0x000a }, + { 0x20a1, 0x000a }, + { 0x40a2, 0x000a }, + }, + }, { + ~0UL, { + { 0x00a0, 0x000a }, + { 0x2001, 0x000f }, + { 0x4002, 0x000f }, + }, + } +}; + +struct curr_ctrl { + unsigned long mpixelclock; + u16 curr[RES_MAX]; +}; + +static const struct curr_ctrl curr_ctrl[] = { + /* pixelclk bpp8 bpp10 bpp12 */ + { + 54000000, { 0x091c, 0x091c, 0x06dc }, + }, { + 58400000, { 0x091c, 0x06dc, 0x06dc }, + }, { + 72000000, { 0x06dc, 0x06dc, 0x091c }, + }, { + 74250000, { 0x06dc, 0x0b5c, 0x091c }, + }, { + 118800000, { 0x091c, 0x091c, 0x06dc }, + }, { + 216000000, { 0x06dc, 0x0b5c, 0x091c }, + } +}; + static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep, unsigned char res, int cscon) { + unsigned res_idx, i; u8 val, msec; - /* color resolution 0 is 8 bit colour depth */ - if (!res) - res = 8; - if (prep) return -EINVAL; - else if (res != 8 && res != 12) + + switch (res) { + case 0: /* color resolution 0 is 8 bit colour depth */ + case 8: + res_idx = RES_8; + break; + case 10: + res_idx = RES_10; + break; + case 12: + res_idx = RES_12; + break; + default: return -EINVAL; + } /* Enable csc path */ if (cscon) @@ -845,165 +920,30 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep, HDMI_PHY_I2CM_SLAVE_ADDR); hdmi_phy_test_clear(hdmi, 0); - if (hdmi->hdmi_data.video_mode.mpixelclock <= 45250000) { - switch (res) { - case 8: - /* PLL/MPLL Cfg */ - hdmi_phy_i2c_write(hdmi, 0x01e0, 0x06); - hdmi_phy_i2c_write(hdmi, 0x0000, 0x15); /* GMPCTRL */ + /* PLL/MPLL Cfg - always match on final entry */ + for (i = 0; i < ARRAY_SIZE(mpll_config) - 1; i++) + if (hdmi->hdmi_data.video_mode.mpixelclock <= + mpll_config[i].mpixelclock) break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x21e1, 0x06); - hdmi_phy_i2c_write(hdmi, 0x0000, 0x15); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x41e2, 0x06); - hdmi_phy_i2c_write(hdmi, 0x0000, 0x15); - break; - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 92500000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x0140, 0x06); - hdmi_phy_i2c_write(hdmi, 0x0005, 0x15); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x2141, 0x06); - hdmi_phy_i2c_write(hdmi, 0x0005, 0x15); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x4142, 0x06); - hdmi_phy_i2c_write(hdmi, 0x0005, 0x15); - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 148500000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x00a0, 0x06); - hdmi_phy_i2c_write(hdmi, 0x000a, 0x15); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x20a1, 0x06); - hdmi_phy_i2c_write(hdmi, 0x000a, 0x15); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x40a2, 0x06); - hdmi_phy_i2c_write(hdmi, 0x000a, 0x15); - default: - return -EINVAL; - } - } else { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x00a0, 0x06); - hdmi_phy_i2c_write(hdmi, 0x000a, 0x15); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x2001, 0x06); - hdmi_phy_i2c_write(hdmi, 0x000f, 0x15); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x4002, 0x06); - hdmi_phy_i2c_write(hdmi, 0x000f, 0x15); - default: - return -EINVAL; - } - } - if (hdmi->hdmi_data.video_mode.mpixelclock <= 54000000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); /* CURRCTRL */ + hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].cpce, 0x06); + hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].gmp, 0x15); + + for (i = 0; i < ARRAY_SIZE(curr_ctrl); i++) + if (hdmi->hdmi_data.video_mode.mpixelclock <= + curr_ctrl[i].mpixelclock) break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 58400000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 72000000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 74250000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x0b5c, 0x10); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 118800000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - default: - return -EINVAL; - } - } else if (hdmi->hdmi_data.video_mode.mpixelclock <= 216000000) { - switch (res) { - case 8: - hdmi_phy_i2c_write(hdmi, 0x06dc, 0x10); - break; - case 10: - hdmi_phy_i2c_write(hdmi, 0x0b5c, 0x10); - break; - case 12: - hdmi_phy_i2c_write(hdmi, 0x091c, 0x10); - break; - default: - return -EINVAL; - } - } else { + + if (i >= ARRAY_SIZE(curr_ctrl)) { dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n", hdmi->hdmi_data.video_mode.mpixelclock); return -EINVAL; } + /* CURRCTRL */ + hdmi_phy_i2c_write(hdmi, curr_ctrl[i].curr[res_idx], 0x10); + hdmi_phy_i2c_write(hdmi, 0x0000, 0x13); /* PLLPHBYCTRL */ hdmi_phy_i2c_write(hdmi, 0x0006, 0x17); /* RESISTANCE TERM 133Ohm Cfg */ From c082f9d7151907da5230f1f20c8da83c9d3188bf Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 4 Nov 2013 12:10:40 +0000 Subject: [PATCH 0402/1375] imx-drm: imx-hdmi: clean up setting CSC registers Rather than manually writing each register sequentially, we can use a loop to reduce the amount of code. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 38 ++++++++++-------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index cb316bf3ec56..18de310e50e0 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -480,6 +480,7 @@ static int is_color_space_interpolation(struct imx_hdmi *hdmi) static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi) { const u16 (*csc_coeff)[3][4] = &csc_coeff_default; + unsigned i; u32 csc_scale = 1; u8 val; @@ -498,32 +499,19 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi) } } - hdmi_writeb(hdmi, ((*csc_coeff)[0][0] & 0xff), HDMI_CSC_COEF_A1_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][0] >> 8), HDMI_CSC_COEF_A1_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][1] & 0xff), HDMI_CSC_COEF_A2_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][1] >> 8), HDMI_CSC_COEF_A2_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][2] & 0xff), HDMI_CSC_COEF_A3_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][2] >> 8), HDMI_CSC_COEF_A3_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][3] & 0xff), HDMI_CSC_COEF_A4_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[0][3] >> 8), HDMI_CSC_COEF_A4_MSB); + /* The CSC registers are sequential, alternating MSB then LSB */ + for (i = 0; i < ARRAY_SIZE(csc_coeff_default[0]); i++) { + u16 coeff_a = (*csc_coeff)[0][i]; + u16 coeff_b = (*csc_coeff)[1][i]; + u16 coeff_c = (*csc_coeff)[2][i]; - hdmi_writeb(hdmi, ((*csc_coeff)[1][0] & 0xff), HDMI_CSC_COEF_B1_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][0] >> 8), HDMI_CSC_COEF_B1_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][1] & 0xff), HDMI_CSC_COEF_B2_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][1] >> 8), HDMI_CSC_COEF_B2_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][2] & 0xff), HDMI_CSC_COEF_B3_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][2] >> 8), HDMI_CSC_COEF_B3_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][3] & 0xff), HDMI_CSC_COEF_B4_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[1][3] >> 8), HDMI_CSC_COEF_B4_MSB); - - hdmi_writeb(hdmi, ((*csc_coeff)[2][0] & 0xff), HDMI_CSC_COEF_C1_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][0] >> 8), HDMI_CSC_COEF_C1_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][1] & 0xff), HDMI_CSC_COEF_C2_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][1] >> 8), HDMI_CSC_COEF_C2_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][2] & 0xff), HDMI_CSC_COEF_C3_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][2] >> 8), HDMI_CSC_COEF_C3_MSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][3] & 0xff), HDMI_CSC_COEF_C4_LSB); - hdmi_writeb(hdmi, ((*csc_coeff)[2][3] >> 8), HDMI_CSC_COEF_C4_MSB); + hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2); + hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2); + hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2); + hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2); + hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2); + hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); + } val = hdmi_readb(hdmi, HDMI_CSC_SCALE); val &= ~HDMI_CSC_SCALE_CSCSCALE_MASK; From 812bc615fd807d9fa1ad57de40061149cef3e7d4 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 4 Nov 2013 12:42:02 +0000 Subject: [PATCH 0403/1375] imx-drm: imx-hdmi: provide register modification function There are a load of read-modify-write patterns to change bitfields in various registers in this driver; provide a helper to perform this manipulation. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 182 +++++++++++------------------ 1 file changed, 65 insertions(+), 117 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 18de310e50e0..2fa8658cebd4 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -156,37 +156,34 @@ static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset) return readb(hdmi->regs + offset); } +static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg) +{ + u8 val = hdmi_readb(hdmi, reg) & ~mask; + val |= data & mask; + hdmi_writeb(hdmi, val, reg); +} + static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg, u8 shift, u8 mask) { - u8 value = hdmi_readb(hdmi, reg) & ~mask; - value |= (data << shift) & mask; - hdmi_writeb(hdmi, value, reg); + hdmi_modb(hdmi, data << shift, mask, reg); } static void hdmi_set_clock_regenerator_n(struct imx_hdmi *hdmi, unsigned int value) { - u8 val; - hdmi_writeb(hdmi, value & 0xff, HDMI_AUD_N1); hdmi_writeb(hdmi, (value >> 8) & 0xff, HDMI_AUD_N2); hdmi_writeb(hdmi, (value >> 16) & 0x0f, HDMI_AUD_N3); /* nshift factor = 0 */ - val = hdmi_readb(hdmi, HDMI_AUD_CTS3); - val &= ~HDMI_AUD_CTS3_N_SHIFT_MASK; - hdmi_writeb(hdmi, val, HDMI_AUD_CTS3); + hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_N_SHIFT_MASK, HDMI_AUD_CTS3); } static void hdmi_regenerate_cts(struct imx_hdmi *hdmi, unsigned int cts) { - u8 val; - /* Must be set/cleared first */ - val = hdmi_readb(hdmi, HDMI_AUD_CTS3); - val &= ~HDMI_AUD_CTS3_CTS_MANUAL; - hdmi_writeb(hdmi, val, HDMI_AUD_CTS3); + hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); hdmi_writeb(hdmi, cts & 0xff, HDMI_AUD_CTS1); hdmi_writeb(hdmi, (cts >> 8) & 0xff, HDMI_AUD_CTS2); @@ -482,7 +479,6 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi) const u16 (*csc_coeff)[3][4] = &csc_coeff_default; unsigned i; u32 csc_scale = 1; - u8 val; if (is_color_space_conversion(hdmi)) { if (hdmi->hdmi_data.enc_out_format == RGB) { @@ -513,10 +509,8 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi *hdmi) hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); } - val = hdmi_readb(hdmi, HDMI_CSC_SCALE); - val &= ~HDMI_CSC_SCALE_CSCSCALE_MASK; - val |= csc_scale & HDMI_CSC_SCALE_CSCSCALE_MASK; - hdmi_writeb(hdmi, val, HDMI_CSC_SCALE); + hdmi_modb(hdmi, csc_scale, HDMI_CSC_SCALE_CSCSCALE_MASK, + HDMI_CSC_SCALE); } static void hdmi_video_csc(struct imx_hdmi *hdmi) @@ -524,7 +518,6 @@ static void hdmi_video_csc(struct imx_hdmi *hdmi) int color_depth = 0; int interpolation = HDMI_CSC_CFG_INTMODE_DISABLE; int decimation = 0; - u8 val; /* YCC422 interpolation to 444 mode */ if (is_color_space_interpolation(hdmi)) @@ -545,10 +538,8 @@ static void hdmi_video_csc(struct imx_hdmi *hdmi) /* Configure the CSC registers */ hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG); - val = hdmi_readb(hdmi, HDMI_CSC_SCALE); - val &= ~HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK; - val |= color_depth; - hdmi_writeb(hdmi, val, HDMI_CSC_SCALE); + hdmi_modb(hdmi, color_depth, HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK, + HDMI_CSC_SCALE); imx_hdmi_update_csc_coeffs(hdmi); } @@ -603,107 +594,80 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi) HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK); hdmi_writeb(hdmi, val, HDMI_VP_PR_CD); - val = hdmi_readb(hdmi, HDMI_VP_STUFF); - val &= ~HDMI_VP_STUFF_PR_STUFFING_MASK; - val |= HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE; - hdmi_writeb(hdmi, val, HDMI_VP_STUFF); + hdmi_modb(hdmi, HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE, + HDMI_VP_STUFF_PR_STUFFING_MASK, HDMI_VP_STUFF); /* Data from pixel repeater block */ if (hdmi_data->pix_repet_factor > 1) { - val = hdmi_readb(hdmi, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_PR_EN_MASK | - HDMI_VP_CONF_BYPASS_SELECT_MASK); - val |= HDMI_VP_CONF_PR_EN_ENABLE | - HDMI_VP_CONF_BYPASS_SELECT_PIX_REPEATER; - hdmi_writeb(hdmi, val, HDMI_VP_CONF); + hdmi_modb(hdmi, HDMI_VP_CONF_PR_EN_ENABLE | + HDMI_VP_CONF_BYPASS_SELECT_PIX_REPEATER, + HDMI_VP_CONF_PR_EN_MASK | + HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); } else { /* data from packetizer block */ - val = hdmi_readb(hdmi, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_PR_EN_MASK | - HDMI_VP_CONF_BYPASS_SELECT_MASK); - val |= HDMI_VP_CONF_PR_EN_DISABLE | - HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER; - hdmi_writeb(hdmi, val, HDMI_VP_CONF); + hdmi_modb(hdmi, HDMI_VP_CONF_PR_EN_DISABLE | + HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER, + HDMI_VP_CONF_PR_EN_MASK | + HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); } - val = hdmi_readb(hdmi, HDMI_VP_STUFF); - val &= ~HDMI_VP_STUFF_IDEFAULT_PHASE_MASK; - val |= 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET; - hdmi_writeb(hdmi, val, HDMI_VP_STUFF); + hdmi_modb(hdmi, 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET, + HDMI_VP_STUFF_IDEFAULT_PHASE_MASK, HDMI_VP_STUFF); hdmi_writeb(hdmi, remap_size, HDMI_VP_REMAP); if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_PP) { - val = hdmi_readb(hdmi, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK); - val |= HDMI_VP_CONF_BYPASS_EN_DISABLE | - HDMI_VP_CONF_PP_EN_ENABLE | - HDMI_VP_CONF_YCC422_EN_DISABLE; - hdmi_writeb(hdmi, val, HDMI_VP_CONF); + hdmi_modb(hdmi, HDMI_VP_CONF_BYPASS_EN_DISABLE | + HDMI_VP_CONF_PP_EN_ENABLE | + HDMI_VP_CONF_YCC422_EN_DISABLE, + HDMI_VP_CONF_BYPASS_EN_MASK | + HDMI_VP_CONF_PP_EN_ENMASK | + HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422) { - val = hdmi_readb(hdmi, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK); - val |= HDMI_VP_CONF_BYPASS_EN_DISABLE | - HDMI_VP_CONF_PP_EN_DISABLE | - HDMI_VP_CONF_YCC422_EN_ENABLE; - hdmi_writeb(hdmi, val, HDMI_VP_CONF); + hdmi_modb(hdmi, HDMI_VP_CONF_BYPASS_EN_DISABLE | + HDMI_VP_CONF_PP_EN_DISABLE | + HDMI_VP_CONF_YCC422_EN_ENABLE, + HDMI_VP_CONF_BYPASS_EN_MASK | + HDMI_VP_CONF_PP_EN_ENMASK | + HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS) { - val = hdmi_readb(hdmi, HDMI_VP_CONF); - val &= ~(HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK); - val |= HDMI_VP_CONF_BYPASS_EN_ENABLE | - HDMI_VP_CONF_PP_EN_DISABLE | - HDMI_VP_CONF_YCC422_EN_DISABLE; - hdmi_writeb(hdmi, val, HDMI_VP_CONF); + hdmi_modb(hdmi, HDMI_VP_CONF_BYPASS_EN_ENABLE | + HDMI_VP_CONF_PP_EN_DISABLE | + HDMI_VP_CONF_YCC422_EN_DISABLE, + HDMI_VP_CONF_BYPASS_EN_MASK | + HDMI_VP_CONF_PP_EN_ENMASK | + HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); } else { return; } - val = hdmi_readb(hdmi, HDMI_VP_STUFF); - val &= ~(HDMI_VP_STUFF_PP_STUFFING_MASK | - HDMI_VP_STUFF_YCC422_STUFFING_MASK); - val |= HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | - HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE; - hdmi_writeb(hdmi, val, HDMI_VP_STUFF); + hdmi_modb(hdmi, HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | + HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE, + HDMI_VP_STUFF_PP_STUFFING_MASK | + HDMI_VP_STUFF_YCC422_STUFFING_MASK, HDMI_VP_STUFF); - val = hdmi_readb(hdmi, HDMI_VP_CONF); - val &= ~HDMI_VP_CONF_OUTPUT_SELECTOR_MASK; - val |= output_select; - hdmi_writeb(hdmi, val, HDMI_VP_CONF); + hdmi_modb(hdmi, output_select, HDMI_VP_CONF_OUTPUT_SELECTOR_MASK, + HDMI_VP_CONF); } static inline void hdmi_phy_test_clear(struct imx_hdmi *hdmi, unsigned char bit) { - u8 val = hdmi_readb(hdmi, HDMI_PHY_TST0); - val &= ~HDMI_PHY_TST0_TSTCLR_MASK; - val |= (bit << HDMI_PHY_TST0_TSTCLR_OFFSET) & - HDMI_PHY_TST0_TSTCLR_MASK; - hdmi_writeb(hdmi, val, HDMI_PHY_TST0); + hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLR_OFFSET, + HDMI_PHY_TST0_TSTCLR_MASK, HDMI_PHY_TST0); } static inline void hdmi_phy_test_enable(struct imx_hdmi *hdmi, unsigned char bit) { - u8 val = hdmi_readb(hdmi, HDMI_PHY_TST0); - val &= ~HDMI_PHY_TST0_TSTEN_MASK; - val |= (bit << HDMI_PHY_TST0_TSTEN_OFFSET) & - HDMI_PHY_TST0_TSTEN_MASK; - hdmi_writeb(hdmi, val, HDMI_PHY_TST0); + hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTEN_OFFSET, + HDMI_PHY_TST0_TSTEN_MASK, HDMI_PHY_TST0); } static inline void hdmi_phy_test_clock(struct imx_hdmi *hdmi, unsigned char bit) { - u8 val = hdmi_readb(hdmi, HDMI_PHY_TST0); - val &= ~HDMI_PHY_TST0_TSTCLK_MASK; - val |= (bit << HDMI_PHY_TST0_TSTCLK_OFFSET) & - HDMI_PHY_TST0_TSTCLK_MASK; - hdmi_writeb(hdmi, val, HDMI_PHY_TST0); + hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLK_OFFSET, + HDMI_PHY_TST0_TSTCLK_MASK, HDMI_PHY_TST0); } static inline void hdmi_phy_test_din(struct imx_hdmi *hdmi, @@ -1000,7 +964,7 @@ static int imx_hdmi_phy_init(struct imx_hdmi *hdmi) static void hdmi_tx_hdcp_config(struct imx_hdmi *hdmi) { - u8 de, val; + u8 de; if (hdmi->hdmi_data.video_mode.mdataenablepolarity) de = HDMI_A_VIDPOLCFG_DATAENPOL_ACTIVE_HIGH; @@ -1008,20 +972,13 @@ static void hdmi_tx_hdcp_config(struct imx_hdmi *hdmi) de = HDMI_A_VIDPOLCFG_DATAENPOL_ACTIVE_LOW; /* disable rx detect */ - val = hdmi_readb(hdmi, HDMI_A_HDCPCFG0); - val &= HDMI_A_HDCPCFG0_RXDETECT_MASK; - val |= HDMI_A_HDCPCFG0_RXDETECT_DISABLE; - hdmi_writeb(hdmi, val, HDMI_A_HDCPCFG0); + hdmi_modb(hdmi, HDMI_A_HDCPCFG0_RXDETECT_DISABLE, + HDMI_A_HDCPCFG0_RXDETECT_MASK, HDMI_A_HDCPCFG0); - val = hdmi_readb(hdmi, HDMI_A_VIDPOLCFG); - val &= HDMI_A_VIDPOLCFG_DATAENPOL_MASK; - val |= de; - hdmi_writeb(hdmi, val, HDMI_A_VIDPOLCFG); + hdmi_modb(hdmi, de, HDMI_A_VIDPOLCFG_DATAENPOL_MASK, HDMI_A_VIDPOLCFG); - val = hdmi_readb(hdmi, HDMI_A_HDCPCFG1); - val &= HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_MASK; - val |= HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_DISABLE; - hdmi_writeb(hdmi, val, HDMI_A_HDCPCFG1); + hdmi_modb(hdmi, HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_DISABLE, + HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_MASK, HDMI_A_HDCPCFG1); } static void hdmi_config_AVI(struct imx_hdmi *hdmi) @@ -1245,11 +1202,7 @@ static void imx_hdmi_enable_video_path(struct imx_hdmi *hdmi) static void hdmi_enable_audio_clk(struct imx_hdmi *hdmi) { - u8 clkdis; - - clkdis = hdmi_readb(hdmi, HDMI_MC_CLKDIS); - clkdis &= ~HDMI_MC_CLKDIS_AUDCLK_DISABLE; - hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); + hdmi_modb(hdmi, 0, HDMI_MC_CLKDIS_AUDCLK_DISABLE, HDMI_MC_CLKDIS); } /* Workaround to clear the overflow condition */ @@ -1593,7 +1546,6 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) struct imx_hdmi *hdmi = dev_id; u8 intr_stat; u8 phy_int_pol; - u8 val; intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); @@ -1603,17 +1555,13 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) if (phy_int_pol & HDMI_PHY_HPD) { dev_dbg(hdmi->dev, "EVENT=plugin\n"); - val = hdmi_readb(hdmi, HDMI_PHY_POL0); - val &= ~HDMI_PHY_HPD; - hdmi_writeb(hdmi, val, HDMI_PHY_POL0); + hdmi_modb(hdmi, 0, HDMI_PHY_HPD, HDMI_PHY_POL0); imx_hdmi_poweron(hdmi); } else { dev_dbg(hdmi->dev, "EVENT=plugout\n"); - val = hdmi_readb(hdmi, HDMI_PHY_POL0); - val |= HDMI_PHY_HPD; - hdmi_writeb(hdmi, val, HDMI_PHY_POL0); + hdmi_modb(hdmi, HDMI_PHY_HPD, HDMI_PHY_HPD, HDMI_PHY_POL0); imx_hdmi_poweroff(hdmi); } From bebdf6641939b1bb869ac96ae9524cedeb11e419 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 4 Nov 2013 12:55:30 +0000 Subject: [PATCH 0404/1375] imx-drm: imx-hdmi: clean up setting of vp_conf Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 49 ++++++++++++++---------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 2fa8658cebd4..ec5b5e2ada34 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -555,7 +555,7 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi) unsigned int remap_size = HDMI_VP_REMAP_YCC422_16bit; unsigned int output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_PP; struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; - u8 val; + u8 val, vp_conf; if (hdmi_data->enc_out_format == RGB || hdmi_data->enc_out_format == YCBCR444) { @@ -599,47 +599,42 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi) /* Data from pixel repeater block */ if (hdmi_data->pix_repet_factor > 1) { - hdmi_modb(hdmi, HDMI_VP_CONF_PR_EN_ENABLE | - HDMI_VP_CONF_BYPASS_SELECT_PIX_REPEATER, - HDMI_VP_CONF_PR_EN_MASK | - HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); + vp_conf = HDMI_VP_CONF_PR_EN_ENABLE | + HDMI_VP_CONF_BYPASS_SELECT_PIX_REPEATER; } else { /* data from packetizer block */ - hdmi_modb(hdmi, HDMI_VP_CONF_PR_EN_DISABLE | - HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER, - HDMI_VP_CONF_PR_EN_MASK | - HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); + vp_conf = HDMI_VP_CONF_PR_EN_DISABLE | + HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER; } + hdmi_modb(hdmi, vp_conf, + HDMI_VP_CONF_PR_EN_MASK | + HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); + hdmi_modb(hdmi, 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET, HDMI_VP_STUFF_IDEFAULT_PHASE_MASK, HDMI_VP_STUFF); hdmi_writeb(hdmi, remap_size, HDMI_VP_REMAP); if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_PP) { - hdmi_modb(hdmi, HDMI_VP_CONF_BYPASS_EN_DISABLE | - HDMI_VP_CONF_PP_EN_ENABLE | - HDMI_VP_CONF_YCC422_EN_DISABLE, - HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); + vp_conf = HDMI_VP_CONF_BYPASS_EN_DISABLE | + HDMI_VP_CONF_PP_EN_ENABLE | + HDMI_VP_CONF_YCC422_EN_DISABLE; } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422) { - hdmi_modb(hdmi, HDMI_VP_CONF_BYPASS_EN_DISABLE | - HDMI_VP_CONF_PP_EN_DISABLE | - HDMI_VP_CONF_YCC422_EN_ENABLE, - HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); + vp_conf = HDMI_VP_CONF_BYPASS_EN_DISABLE | + HDMI_VP_CONF_PP_EN_DISABLE | + HDMI_VP_CONF_YCC422_EN_ENABLE; } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS) { - hdmi_modb(hdmi, HDMI_VP_CONF_BYPASS_EN_ENABLE | - HDMI_VP_CONF_PP_EN_DISABLE | - HDMI_VP_CONF_YCC422_EN_DISABLE, - HDMI_VP_CONF_BYPASS_EN_MASK | - HDMI_VP_CONF_PP_EN_ENMASK | - HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); + vp_conf = HDMI_VP_CONF_BYPASS_EN_ENABLE | + HDMI_VP_CONF_PP_EN_DISABLE | + HDMI_VP_CONF_YCC422_EN_DISABLE; } else { return; } + hdmi_modb(hdmi, vp_conf, + HDMI_VP_CONF_BYPASS_EN_MASK | HDMI_VP_CONF_PP_EN_ENMASK | + HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); + hdmi_modb(hdmi, HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE, HDMI_VP_STUFF_PP_STUFFING_MASK | From 406783880267c3fa3d76ce8e9a83ba17de3bcf2e Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 7 Nov 2013 15:35:06 +0000 Subject: [PATCH 0405/1375] imx-drm: imx-hdmi: fix CTS/N setup at init time Many of the variables for the audio clock regenerator (CTS/N) were not initialised in any way. The pixel rate which was being used also wasn't being adjusted at all when the display mode is modified. Get rid of the seaprate 'pixel_clk_rate', and use the stored pixel clock rate instead. Pass this desired pixel clock rate into hdmi_set_clk_regenerator(). Collapse down hdmi_init_clk_regenerator() since it is a copy of hdmi_set_clk_regenerator(), and pass a default pixel clock rate. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 48 +++++++----------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index ec5b5e2ada34..05cf8a07b456 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -134,7 +134,6 @@ struct imx_hdmi { struct i2c_adapter *ddc; void __iomem *regs; - unsigned long pixel_clk_rate; unsigned int sample_rate; int ratio; }; @@ -328,34 +327,25 @@ static unsigned int hdmi_compute_cts(unsigned int freq, unsigned long pixel_clk, return (cts * ratio) / 100; } -static void hdmi_get_pixel_clk(struct imx_hdmi *hdmi) -{ - unsigned long rate; - - rate = 65000000; /* FIXME */ - - if (rate) - hdmi->pixel_clk_rate = rate; -} - -static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi) +static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi, + unsigned long pixel_clk) { unsigned int clk_n, clk_cts; - clk_n = hdmi_compute_n(hdmi->sample_rate, hdmi->pixel_clk_rate, + clk_n = hdmi_compute_n(hdmi->sample_rate, pixel_clk, hdmi->ratio); - clk_cts = hdmi_compute_cts(hdmi->sample_rate, hdmi->pixel_clk_rate, + clk_cts = hdmi_compute_cts(hdmi->sample_rate, pixel_clk, hdmi->ratio); if (!clk_cts) { dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n", - __func__, hdmi->pixel_clk_rate); + __func__, pixel_clk); return; } dev_dbg(hdmi->dev, "%s: samplerate=%d ratio=%d pixelclk=%lu N=%d cts=%d\n", __func__, hdmi->sample_rate, hdmi->ratio, - hdmi->pixel_clk_rate, clk_n, clk_cts); + pixel_clk, clk_n, clk_cts); hdmi_set_clock_regenerator_n(hdmi, clk_n); hdmi_regenerate_cts(hdmi, clk_cts); @@ -363,32 +353,12 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi) static void hdmi_init_clk_regenerator(struct imx_hdmi *hdmi) { - unsigned int clk_n, clk_cts; - - clk_n = hdmi_compute_n(hdmi->sample_rate, hdmi->pixel_clk_rate, - hdmi->ratio); - clk_cts = hdmi_compute_cts(hdmi->sample_rate, hdmi->pixel_clk_rate, - hdmi->ratio); - - if (!clk_cts) { - dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n", - __func__, hdmi->pixel_clk_rate); - return; - } - - dev_dbg(hdmi->dev, "%s: samplerate=%d ratio=%d pixelclk=%lu N=%d cts=%d\n", - __func__, hdmi->sample_rate, hdmi->ratio, - hdmi->pixel_clk_rate, clk_n, clk_cts); - - hdmi_set_clock_regenerator_n(hdmi, clk_n); - hdmi_regenerate_cts(hdmi, clk_cts); + hdmi_set_clk_regenerator(hdmi, 74250000); } static void hdmi_clk_regenerator_update_pixel_clock(struct imx_hdmi *hdmi) { - /* Get pixel clock from ipu */ - hdmi_get_pixel_clk(hdmi); - hdmi_set_clk_regenerator(hdmi); + hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock); } /* @@ -1636,6 +1606,8 @@ static int imx_hdmi_platform_probe(struct platform_device *pdev) return -ENOMEM; hdmi->dev = &pdev->dev; + hdmi->sample_rate = 48000; + hdmi->ratio = 100; if (of_id) { const struct platform_device_id *device_id = of_id->data; From 24013ea8ff5711ef548b709d2f93d541f0bf504a Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 19 Oct 2013 15:05:31 +0100 Subject: [PATCH 0406/1375] imx-drm: ipu-v3: more inteligent DI clock selection The DI clock selection was very rudimentary: it would statically use either the IPU internal clock or the DI external clock depending on which "encoder" was being used. In the case of HDMI, it would always use the IPU clock. Moreover, using the IPU clock resulted in fractional divisors, which are achieved by skipping clock pulses. This can result in the HDMI PHY PLL being frequency modulated, and the attached device is then unable to properly lock on to the TMDS clock. We need at least 1% accurate and stable clocks for HDMI. Arrange for the DI clock to be sourced from the IPU internal clock if it can satisfy our requirements, otherwise switch to the DI external clock and try and set the external clock to our desired pixel clock rate. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-di.c | 54 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index 948a49b289ef..8c7241bb435c 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -544,10 +544,48 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) if ((sig->v_sync_width == 0) || (sig->h_sync_width == 0)) return -EINVAL; + dev_dbg(di->ipu->dev, "Clocks: IPU %luHz DI %luHz Needed %luHz\n", + clk_get_rate(di->clk_ipu), + clk_get_rate(di->clk_di), + sig->pixelclock); + + /* + * CLKMODE_EXT means we must use the DI clock: this is needed + * for things like LVDS which needs to feed the DI and LDB with + * the same pixel clock. + * + * For other interfaces, we can arbitarily select between the DI + * specific clock and the internal IPU clock. See DI_GENERAL + * bit 20. We select the IPU clock if it can give us a clock + * rate within 1% of the requested frequency, otherwise we use + * the DI clock. + */ if (sig->clkflags & IPU_DI_CLKMODE_EXT) parent = di->clk_di; - else - parent = di->clk_ipu; + else { + unsigned long rate, clkrate; + unsigned div, error; + + clkrate = clk_get_rate(di->clk_ipu); + div = (clkrate + sig->pixelclock / 2) / sig->pixelclock; + rate = clkrate / div; + + error = rate / (sig->pixelclock / 1000); + + dev_dbg(di->ipu->dev, " IPU clock can give %lu with divider %u, error %d.%u%%\n", + rate, div, (signed)(error - 1000) / 10, error % 10); + + /* Allow a 1% error */ + if (error < 1010 && error >= 990) { + parent = di->clk_ipu; + } else { + parent = di->clk_di; + + ret = clk_set_rate(parent, sig->pixelclock); + if (ret) + dev_err(di->ipu->dev, "Setting of DI clock failed: %d\n", ret); + } + } ret = clk_set_parent(di->clk_di_pixel, parent); if (ret) { @@ -557,6 +595,11 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) return ret; } + /* + * CLKMODE_SYNC means that we want the DI to be clocked at the + * same rate as the parent clock. This is needed (eg) for LDB + * which needs to be fed with the same pixel clock. + */ if (sig->clkflags & IPU_DI_CLKMODE_SYNC) round = clk_get_rate(parent); else @@ -564,6 +607,13 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) ret = clk_set_rate(di->clk_di_pixel, round); + dev_dbg(di->ipu->dev, "Want %luHz IPU %luHz DI %luHz using %s, got %luHz\n", + sig->pixelclock, + clk_get_rate(di->clk_ipu), + clk_get_rate(di->clk_di), + parent == di->clk_di ? "DI" : "IPU", + clk_get_rate(di->clk_di_pixel)); + h_total = sig->width + sig->h_sync_width + sig->h_start_width + sig->h_end_width; v_total = sig->height + sig->v_sync_width + sig->v_start_width + From 370b181516f205a9761767808e4702832834faf1 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 19 Oct 2013 17:38:44 +0100 Subject: [PATCH 0407/1375] imx-drm: ipu-v3: don't use clk_round_rate() before clk_set_rate() This is nonsense; clk_round_rate() is just clk_set_rate() without the side effect of changing the hardware. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-di.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index 8c7241bb435c..d766e18bfca0 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -560,9 +560,10 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) * rate within 1% of the requested frequency, otherwise we use * the DI clock. */ - if (sig->clkflags & IPU_DI_CLKMODE_EXT) + round = sig->pixelclock; + if (sig->clkflags & IPU_DI_CLKMODE_EXT) { parent = di->clk_di; - else { + } else { unsigned long rate, clkrate; unsigned div, error; @@ -584,6 +585,9 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) ret = clk_set_rate(parent, sig->pixelclock); if (ret) dev_err(di->ipu->dev, "Setting of DI clock failed: %d\n", ret); + + /* Use the integer divisor rate - avoid fractional dividers */ + round = rate; } } @@ -599,11 +603,12 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) * CLKMODE_SYNC means that we want the DI to be clocked at the * same rate as the parent clock. This is needed (eg) for LDB * which needs to be fed with the same pixel clock. + * + * Note: clk_set_rate(clk, clk_round_rate(clk, rate)) is the + * same as clk_set_rate(clk, rate); */ if (sig->clkflags & IPU_DI_CLKMODE_SYNC) round = clk_get_rate(parent); - else - round = clk_round_rate(di->clk_di_pixel, sig->pixelclock); ret = clk_set_rate(di->clk_di_pixel, round); From 0721feeee09bdb1ea97b75948f2ab2861d9ee38e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 20 Oct 2013 15:36:35 +0100 Subject: [PATCH 0408/1375] imx-drm: ipu-v3: more clocking fixes There's no point in using the clk API for this; we end up having to violate the layering this provides. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-di.c | 332 ++++++++---------------- 1 file changed, 107 insertions(+), 225 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index d766e18bfca0..82a9ebad697c 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -19,9 +19,6 @@ #include #include #include -#include -#include -#include #include "imx-ipu-v3.h" #include "ipu-prv.h" @@ -33,10 +30,7 @@ struct ipu_di { struct clk *clk_di; /* display input clock */ struct clk *clk_ipu; /* IPU bus clock */ struct clk *clk_di_pixel; /* resulting pixel clock */ - struct clk_hw clk_hw_out; - char *clk_name; bool inuse; - unsigned long clkflags; struct ipu_soc *ipu; }; @@ -141,130 +135,6 @@ static inline void ipu_di_write(struct ipu_di *di, u32 value, unsigned offset) writel(value, di->base + offset); } -static int ipu_di_clk_calc_div(unsigned long inrate, unsigned long outrate) -{ - u64 tmp = inrate; - int div; - - tmp *= 16; - - do_div(tmp, outrate); - - div = tmp; - - if (div < 0x10) - div = 0x10; - -#ifdef WTF_IS_THIS - /* - * Freescale has this in their Kernel. It is neither clear what - * it does nor why it does it - */ - if (div & 0x10) - div &= ~0x7; - else { - /* Round up divider if it gets us closer to desired pix clk */ - if ((div & 0xC) == 0xC) { - div += 0x10; - div &= ~0xF; - } - } -#endif - return div; -} - -static unsigned long clk_di_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) -{ - struct ipu_di *di = container_of(hw, struct ipu_di, clk_hw_out); - unsigned long outrate; - u32 div = ipu_di_read(di, DI_BS_CLKGEN0); - - if (div < 0x10) - div = 0x10; - - outrate = (parent_rate / div) * 16; - - return outrate; -} - -static long clk_di_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate) -{ - struct ipu_di *di = container_of(hw, struct ipu_di, clk_hw_out); - unsigned long outrate; - int div; - u32 val; - - div = ipu_di_clk_calc_div(*prate, rate); - - outrate = (*prate / div) * 16; - - val = ipu_di_read(di, DI_GENERAL); - - if (!(val & DI_GEN_DI_CLK_EXT) && outrate > *prate / 2) - outrate = *prate / 2; - - dev_dbg(di->ipu->dev, - "%s: inrate: %ld div: 0x%08x outrate: %ld wanted: %ld\n", - __func__, *prate, div, outrate, rate); - - return outrate; -} - -static int clk_di_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) -{ - struct ipu_di *di = container_of(hw, struct ipu_di, clk_hw_out); - int div; - u32 clkgen0; - - clkgen0 = ipu_di_read(di, DI_BS_CLKGEN0) & ~0xfff; - - div = ipu_di_clk_calc_div(parent_rate, rate); - - ipu_di_write(di, clkgen0 | div, DI_BS_CLKGEN0); - - dev_dbg(di->ipu->dev, "%s: inrate: %ld desired: %ld div: 0x%08x\n", - __func__, parent_rate, rate, div); - return 0; -} - -static u8 clk_di_get_parent(struct clk_hw *hw) -{ - struct ipu_di *di = container_of(hw, struct ipu_di, clk_hw_out); - u32 val; - - val = ipu_di_read(di, DI_GENERAL); - - return val & DI_GEN_DI_CLK_EXT ? 1 : 0; -} - -static int clk_di_set_parent(struct clk_hw *hw, u8 index) -{ - struct ipu_di *di = container_of(hw, struct ipu_di, clk_hw_out); - u32 val; - - val = ipu_di_read(di, DI_GENERAL); - - if (index) - val |= DI_GEN_DI_CLK_EXT; - else - val &= ~DI_GEN_DI_CLK_EXT; - - ipu_di_write(di, val, DI_GENERAL); - - return 0; -} - -static struct clk_ops clk_di_ops = { - .round_rate = clk_di_round_rate, - .set_rate = clk_di_set_rate, - .recalc_rate = clk_di_recalc_rate, - .set_parent = clk_di_set_parent, - .get_parent = clk_di_get_parent, -}; - static void ipu_di_data_wave_config(struct ipu_di *di, int wave_gen, int access_size, int component_size) @@ -528,42 +398,58 @@ static void ipu_di_sync_config_noninterlaced(struct ipu_di *di, ipu_di_sync_config(di, cfg_vga, 0, ARRAY_SIZE(cfg_vga)); } -int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) +static void ipu_di_config_clock(struct ipu_di *di, + const struct ipu_di_signal_cfg *sig) { - u32 reg; - u32 di_gen, vsync_cnt; - u32 div; - u32 h_total, v_total; - int ret; - unsigned long round; - struct clk *parent; + struct clk *clk; + unsigned clkgen0; + uint32_t val; - dev_dbg(di->ipu->dev, "disp %d: panel size = %d x %d\n", - di->id, sig->width, sig->height); - - if ((sig->v_sync_width == 0) || (sig->h_sync_width == 0)) - return -EINVAL; - - dev_dbg(di->ipu->dev, "Clocks: IPU %luHz DI %luHz Needed %luHz\n", - clk_get_rate(di->clk_ipu), - clk_get_rate(di->clk_di), - sig->pixelclock); - - /* - * CLKMODE_EXT means we must use the DI clock: this is needed - * for things like LVDS which needs to feed the DI and LDB with - * the same pixel clock. - * - * For other interfaces, we can arbitarily select between the DI - * specific clock and the internal IPU clock. See DI_GENERAL - * bit 20. We select the IPU clock if it can give us a clock - * rate within 1% of the requested frequency, otherwise we use - * the DI clock. - */ - round = sig->pixelclock; if (sig->clkflags & IPU_DI_CLKMODE_EXT) { - parent = di->clk_di; + /* + * CLKMODE_EXT means we must use the DI clock: this is + * needed for things like LVDS which needs to feed the + * DI and LDB with the same pixel clock. + */ + clk = di->clk_di; + + if (sig->clkflags & IPU_DI_CLKMODE_SYNC) { + /* + * CLKMODE_SYNC means that we want the DI to be + * clocked at the same rate as the parent clock. + * This is needed (eg) for LDB which needs to be + * fed with the same pixel clock. We assume that + * the LDB clock has already been set correctly. + */ + clkgen0 = 1 << 4; + } else { + /* + * We can use the divider. We should really have + * a flag here indicating whether the bridge can + * cope with a fractional divider or not. For the + * time being, let's go for simplicitly and + * reliability. + */ + unsigned long in_rate; + unsigned div; + + clk_set_rate(clk, sig->pixelclock); + + in_rate = clk_get_rate(clk); + div = (in_rate + sig->pixelclock / 2) / sig->pixelclock; + if (div == 0) + div = 1; + + clkgen0 = div << 4; + } } else { + /* + * For other interfaces, we can arbitarily select between + * the DI specific clock and the internal IPU clock. See + * DI_GENERAL bit 20. We select the IPU clock if it can + * give us a clock rate within 1% of the requested frequency, + * otherwise we use the DI clock. + */ unsigned long rate, clkrate; unsigned div, error; @@ -578,54 +464,80 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) /* Allow a 1% error */ if (error < 1010 && error >= 990) { - parent = di->clk_ipu; + clk = di->clk_ipu; + + clkgen0 = div << 4; } else { - parent = di->clk_di; + unsigned long in_rate; + unsigned div; - ret = clk_set_rate(parent, sig->pixelclock); - if (ret) - dev_err(di->ipu->dev, "Setting of DI clock failed: %d\n", ret); + clk = di->clk_di; - /* Use the integer divisor rate - avoid fractional dividers */ - round = rate; + clk_set_rate(clk, sig->pixelclock); + + in_rate = clk_get_rate(clk); + div = (in_rate + sig->pixelclock / 2) / sig->pixelclock; + if (div == 0) + div = 1; + + clkgen0 = div << 4; } } - ret = clk_set_parent(di->clk_di_pixel, parent); - if (ret) { - dev_err(di->ipu->dev, - "setting pixel clock to parent %s failed with %d\n", - __clk_get_name(parent), ret); - return ret; - } + di->clk_di_pixel = clk; + + /* Set the divider */ + ipu_di_write(di, clkgen0, DI_BS_CLKGEN0); /* - * CLKMODE_SYNC means that we want the DI to be clocked at the - * same rate as the parent clock. This is needed (eg) for LDB - * which needs to be fed with the same pixel clock. - * - * Note: clk_set_rate(clk, clk_round_rate(clk, rate)) is the - * same as clk_set_rate(clk, rate); + * Set the high/low periods. Bits 24:16 give us the falling edge, + * and bits 8:0 give the rising edge. LSB is fraction, and is + * based on the divider above. We want a 50% duty cycle, so set + * the falling edge to be half the divider. */ - if (sig->clkflags & IPU_DI_CLKMODE_SYNC) - round = clk_get_rate(parent); + ipu_di_write(di, (clkgen0 >> 4) << 16, DI_BS_CLKGEN1); - ret = clk_set_rate(di->clk_di_pixel, round); + /* Finally select the input clock */ + val = ipu_di_read(di, DI_GENERAL) & ~DI_GEN_DI_CLK_EXT; + if (clk == di->clk_di) + val |= DI_GEN_DI_CLK_EXT; + ipu_di_write(di, val, DI_GENERAL); - dev_dbg(di->ipu->dev, "Want %luHz IPU %luHz DI %luHz using %s, got %luHz\n", + dev_dbg(di->ipu->dev, "Want %luHz IPU %luHz DI %luHz using %s, %luHz\n", sig->pixelclock, clk_get_rate(di->clk_ipu), clk_get_rate(di->clk_di), - parent == di->clk_di ? "DI" : "IPU", - clk_get_rate(di->clk_di_pixel)); + clk == di->clk_di ? "DI" : "IPU", + clk_get_rate(di->clk_di_pixel) / (clkgen0 >> 4)); +} + +int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) +{ + u32 reg; + u32 di_gen, vsync_cnt; + u32 div; + u32 h_total, v_total; + + dev_dbg(di->ipu->dev, "disp %d: panel size = %d x %d\n", + di->id, sig->width, sig->height); + + if ((sig->v_sync_width == 0) || (sig->h_sync_width == 0)) + return -EINVAL; h_total = sig->width + sig->h_sync_width + sig->h_start_width + sig->h_end_width; v_total = sig->height + sig->v_sync_width + sig->v_start_width + sig->v_end_width; + dev_dbg(di->ipu->dev, "Clocks: IPU %luHz DI %luHz Needed %luHz\n", + clk_get_rate(di->clk_ipu), + clk_get_rate(di->clk_di), + sig->pixelclock); + mutex_lock(&di_mutex); + ipu_di_config_clock(di, sig); + div = ipu_di_read(di, DI_BS_CLKGEN0) & 0xfff; div = div / 16; /* Now divider is integer portion */ @@ -709,7 +621,11 @@ EXPORT_SYMBOL_GPL(ipu_di_init_sync_panel); int ipu_di_enable(struct ipu_di *di) { - int ret = clk_prepare_enable(di->clk_di_pixel); + int ret; + + WARN_ON(IS_ERR(di->clk_di_pixel)); + + ret = clk_prepare_enable(di->clk_di_pixel); if (ret) return ret; @@ -721,6 +637,8 @@ EXPORT_SYMBOL_GPL(ipu_di_enable); int ipu_di_disable(struct ipu_di *di) { + WARN_ON(IS_ERR(di->clk_di_pixel)); + ipu_module_disable(di->ipu, di->module); clk_disable_unprepare(di->clk_di_pixel); @@ -776,13 +694,6 @@ int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id, u32 module, struct clk *clk_ipu) { struct ipu_di *di; - int ret; - const char *di_parent[2]; - struct clk_init_data init = { - .ops = &clk_di_ops, - .num_parents = 2, - .flags = 0, - }; if (id > 1) return -ENODEV; @@ -804,45 +715,16 @@ int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id, if (!di->base) return -ENOMEM; - di_parent[0] = __clk_get_name(di->clk_ipu); - di_parent[1] = __clk_get_name(di->clk_di); - ipu_di_write(di, 0x10, DI_BS_CLKGEN0); - init.parent_names = (const char **)&di_parent; - di->clk_name = kasprintf(GFP_KERNEL, "%s_di%d_pixel", - dev_name(dev), id); - if (!di->clk_name) - return -ENOMEM; - - init.name = di->clk_name; - - di->clk_hw_out.init = &init; - di->clk_di_pixel = clk_register(dev, &di->clk_hw_out); - - if (IS_ERR(di->clk_di_pixel)) { - ret = PTR_ERR(di->clk_di_pixel); - goto failed_clk_register; - } - dev_dbg(dev, "DI%d base: 0x%08lx remapped to %p\n", id, base, di->base); di->inuse = false; di->ipu = ipu; return 0; - -failed_clk_register: - - kfree(di->clk_name); - - return ret; } void ipu_di_exit(struct ipu_soc *ipu, int id) { - struct ipu_di *di = ipu->di_priv[id]; - - clk_unregister(di->clk_di_pixel); - kfree(di->clk_name); } From 04cec1a2bc5c70e719c1da8eaca2842da4cd77fb Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 16 Oct 2013 10:19:00 +0100 Subject: [PATCH 0409/1375] imx-drm: add imx6 DT configuration for HDMI Extracted from another patch by Fabio Estevam, this adds the DT configuration for HDMI output on the IMX6 SoCs Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- arch/arm/boot/dts/imx6dl.dtsi | 4 ++++ arch/arm/boot/dts/imx6q.dtsi | 4 ++++ arch/arm/boot/dts/imx6qdl.dtsi | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi index 9e8ae118fdd4..65e54b4529c5 100644 --- a/arch/arm/boot/dts/imx6dl.dtsi +++ b/arch/arm/boot/dts/imx6dl.dtsi @@ -88,3 +88,7 @@ crtcs = <&ipu1 0>, <&ipu1 1>; }; }; + +&hdmi { + crtcs = <&ipu1 0>, <&ipu1 1>; +} diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi index f024ef28b34b..d2467f532de6 100644 --- a/arch/arm/boot/dts/imx6q.dtsi +++ b/arch/arm/boot/dts/imx6q.dtsi @@ -159,3 +159,7 @@ crtcs = <&ipu1 0>, <&ipu1 1>, <&ipu2 0>, <&ipu2 1>; }; }; + +&hdmi { + crtcs = <&ipu1 0>, <&ipu1 1>, <&ipu2 0>, <&ipu2 1>; +}; diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index fb28b2ecb1db..400bbc624f25 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi @@ -1368,6 +1368,16 @@ }; }; + hdmi: hdmi@0120000 { + compatible = "fsl,imx6q-hdmi"; + reg = <0x00120000 0x9000>; + interrupts = <0 115 0x04>; + gpr = <&gpr>; + clocks = <&clks 123>, <&clks 124>; + clock-names = "iahb", "isfr"; + status = "disabled"; + }; + dcic1: dcic@020e4000 { reg = <0x020e4000 0x4000>; interrupts = <0 124 0x04>; From cf83eb24d22f3a9580fb86ee64e2830c65df062a Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 30 Oct 2013 20:10:31 +0000 Subject: [PATCH 0410/1375] imx-drm: update and fix imx6 DT descriptions for v3 HDMI driver Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- arch/arm/boot/dts/imx6dl.dtsi | 3 ++- arch/arm/boot/dts/imx6q.dtsi | 1 + arch/arm/boot/dts/imx6qdl.dtsi | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi index 65e54b4529c5..6dc397022214 100644 --- a/arch/arm/boot/dts/imx6dl.dtsi +++ b/arch/arm/boot/dts/imx6dl.dtsi @@ -90,5 +90,6 @@ }; &hdmi { + compatible = "fsl,imx6dl-hdmi"; crtcs = <&ipu1 0>, <&ipu1 1>; -} +}; diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi index d2467f532de6..187fe33ba515 100644 --- a/arch/arm/boot/dts/imx6q.dtsi +++ b/arch/arm/boot/dts/imx6q.dtsi @@ -161,5 +161,6 @@ }; &hdmi { + compatible = "fsl,imx6q-hdmi"; crtcs = <&ipu1 0>, <&ipu1 1>, <&ipu2 0>, <&ipu2 1>; }; diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index 400bbc624f25..930ebe0c2937 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi @@ -1369,7 +1369,6 @@ }; hdmi: hdmi@0120000 { - compatible = "fsl,imx6q-hdmi"; reg = <0x00120000 0x9000>; interrupts = <0 115 0x04>; gpr = <&gpr>; From e76171b046e95e45266f3a4f4b900a5647e80d70 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 24 Nov 2013 13:02:52 +0000 Subject: [PATCH 0411/1375] imx-drm: imx-drm-core: sanitise imx_drm_encoder_get_mux_id() Address the following issues: - imx_drm_encoder_get_mux_id() searches the CRTC list for the matching CRTC, and returns the position within this list as the MUX programming value for encoders. This is sub-optimal for two reasons: 1. It relies upon the CRTC list not changing during the lifetime of the driver. 2. It is dependent on the initialisation order of the CRTCs. We address (1) in this patch, leaving (2) until a better solution can be found, as (2) requires larger changes. - imx_drm_encoder is unused. Instead, pass the drm_encoder which is slightly more useful; all callers pass encoder->crtc as the required crtc, so move this inside the function. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 17 ++++++----------- drivers/staging/imx-drm/imx-drm.h | 3 +-- drivers/staging/imx-drm/imx-hdmi.c | 3 +-- drivers/staging/imx-drm/imx-ldb.c | 6 ++---- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 236ed66f116a..92fde89f58ac 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -53,6 +53,7 @@ struct imx_drm_crtc { struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; struct module *owner; struct crtc_cookie cookie; + int mux_id; }; struct imx_drm_encoder { @@ -503,7 +504,7 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, imx_drm_crtc->pipe = imxdrm->pipes++; imx_drm_crtc->cookie.cookie = cookie; imx_drm_crtc->cookie.id = id; - + imx_drm_crtc->mux_id = imx_drm_crtc->pipe; imx_drm_crtc->crtc = crtc; imx_drm_crtc->imxdrm = imxdrm; @@ -657,22 +658,16 @@ int imx_drm_encoder_add_possible_crtcs( } EXPORT_SYMBOL_GPL(imx_drm_encoder_add_possible_crtcs); -int imx_drm_encoder_get_mux_id(struct imx_drm_encoder *imx_drm_encoder, - struct drm_crtc *crtc) +int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder) { struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_crtc *imx_crtc; - int i = 0; - list_for_each_entry(imx_crtc, &imxdrm->crtc_list, list) { - if (imx_crtc->crtc == crtc) - goto found; - i++; - } + list_for_each_entry(imx_crtc, &imxdrm->crtc_list, list) + if (imx_crtc->crtc == encoder->crtc) + return imx_crtc->mux_id; return -EINVAL; -found: - return i; } EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id); diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index ae90c9c15312..5649f180dc44 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -64,8 +64,7 @@ void imx_drm_fb_helper_set(struct drm_fbdev_cma *fbdev_helper); struct device_node; -int imx_drm_encoder_get_mux_id(struct imx_drm_encoder *imx_drm_encoder, - struct drm_crtc *crtc); +int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder); int imx_drm_encoder_add_possible_crtcs(struct imx_drm_encoder *imx_drm_encoder, struct device_node *np); diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 05cf8a07b456..a90f08d52ee7 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -1467,8 +1467,7 @@ static void imx_hdmi_encoder_prepare(struct drm_encoder *encoder) static void imx_hdmi_encoder_commit(struct drm_encoder *encoder) { struct imx_hdmi *hdmi = container_of(encoder, struct imx_hdmi, encoder); - int mux = imx_drm_encoder_get_mux_id(hdmi->imx_drm_encoder, - encoder->crtc); + int mux = imx_drm_encoder_get_mux_id(encoder); imx_hdmi_set_ipu_di_mux(hdmi, mux); diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index 7e593296ac47..4aa47ae2a3ca 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -179,8 +179,7 @@ static void imx_ldb_encoder_prepare(struct drm_encoder *encoder) u32 pixel_fmt; unsigned long serial_clk; unsigned long di_clk = mode->clock * 1000; - int mux = imx_drm_encoder_get_mux_id(imx_ldb_ch->imx_drm_encoder, - encoder->crtc); + int mux = imx_drm_encoder_get_mux_id(encoder); if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) { /* dual channel LVDS mode */ @@ -216,8 +215,7 @@ static void imx_ldb_encoder_commit(struct drm_encoder *encoder) struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); struct imx_ldb *ldb = imx_ldb_ch->ldb; int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; - int mux = imx_drm_encoder_get_mux_id(imx_ldb_ch->imx_drm_encoder, - encoder->crtc); + int mux = imx_drm_encoder_get_mux_id(encoder); if (dual) { clk_prepare_enable(ldb->clk[0]); From 887eceacc52e3f83fc8dd819c447632d3c0eb7d2 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 24 Nov 2013 13:23:17 +0000 Subject: [PATCH 0412/1375] imx-drm: imx-drm-core: use array instead of list for CRTCs The DRM core indexes vblank by number, so there's little point maintaining a list, and have to scan the list to find the appropriate structure. Instead, use an array of pointers to the CRTCs. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 57 +++++++++++--------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 92fde89f58ac..c5268847a54e 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -34,10 +34,12 @@ struct crtc_cookie { struct list_head list; }; +struct imx_drm_crtc; + struct imx_drm_device { struct drm_device *drm; struct device *dev; - struct list_head crtc_list; + struct imx_drm_crtc *crtc[MAX_CRTC]; struct list_head encoder_list; struct list_head connector_list; struct mutex mutex; @@ -47,7 +49,6 @@ struct imx_drm_device { struct imx_drm_crtc { struct drm_crtc *crtc; - struct list_head list; struct imx_drm_device *imxdrm; int pipe; struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; @@ -69,6 +70,8 @@ struct imx_drm_connector { struct module *owner; }; +static struct imx_drm_device *__imx_drm_device(void); + int imx_drm_crtc_id(struct imx_drm_crtc *crtc) { return crtc->pipe; @@ -96,34 +99,28 @@ static int imx_drm_driver_unload(struct drm_device *drm) return 0; } -/* - * We don't care at all for crtc numbers, but the core expects the - * crtcs to be numbered - */ -static struct imx_drm_crtc *imx_drm_crtc_by_num(struct imx_drm_device *imxdrm, - int num) +struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc) { - struct imx_drm_crtc *imx_drm_crtc; + struct imx_drm_device *imxdrm = __imx_drm_device(); + unsigned i; + + for (i = 0; i < MAX_CRTC; i++) + if (imxdrm->crtc[i] && imxdrm->crtc[i]->crtc == crtc) + return imxdrm->crtc[i]; - list_for_each_entry(imx_drm_crtc, &imxdrm->crtc_list, list) - if (imx_drm_crtc->pipe == num) - return imx_drm_crtc; return NULL; } int imx_drm_crtc_panel_format_pins(struct drm_crtc *crtc, u32 encoder_type, u32 interface_pix_fmt, int hsync_pin, int vsync_pin) { - struct imx_drm_device *imxdrm = crtc->dev->dev_private; - struct imx_drm_crtc *imx_crtc; struct imx_drm_crtc_helper_funcs *helper; + struct imx_drm_crtc *imx_crtc; - list_for_each_entry(imx_crtc, &imxdrm->crtc_list, list) - if (imx_crtc->crtc == crtc) - goto found; + imx_crtc = imx_drm_find_crtc(crtc); + if (!imx_crtc) + return -EINVAL; - return -EINVAL; -found: helper = &imx_crtc->imx_drm_helper_funcs; if (helper->set_interface_pix_fmt) return helper->set_interface_pix_fmt(crtc, @@ -162,10 +159,9 @@ EXPORT_SYMBOL_GPL(imx_drm_handle_vblank); static int imx_drm_enable_vblank(struct drm_device *drm, int crtc) { struct imx_drm_device *imxdrm = drm->dev_private; - struct imx_drm_crtc *imx_drm_crtc; + struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[crtc]; int ret; - imx_drm_crtc = imx_drm_crtc_by_num(imxdrm, crtc); if (!imx_drm_crtc) return -EINVAL; @@ -181,9 +177,8 @@ static int imx_drm_enable_vblank(struct drm_device *drm, int crtc) static void imx_drm_disable_vblank(struct drm_device *drm, int crtc) { struct imx_drm_device *imxdrm = drm->dev_private; - struct imx_drm_crtc *imx_drm_crtc; + struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[crtc]; - imx_drm_crtc = imx_drm_crtc_by_num(imxdrm, crtc); if (!imx_drm_crtc) return; @@ -510,7 +505,7 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, imx_drm_crtc->owner = owner; - list_add_tail(&imx_drm_crtc->list, &imxdrm->crtc_list); + imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc; *new_crtc = imx_drm_crtc; @@ -533,7 +528,7 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, return 0; err_register: - list_del(&imx_drm_crtc->list); + imxdrm->crtc[imx_drm_crtc->pipe] = NULL; kfree(imx_drm_crtc); err_alloc: err_busy: @@ -553,7 +548,7 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) drm_crtc_cleanup(imx_drm_crtc->crtc); - list_del(&imx_drm_crtc->list); + imxdrm->crtc[imx_drm_crtc->pipe] = NULL; drm_mode_group_reinit(imxdrm->drm); @@ -660,14 +655,9 @@ EXPORT_SYMBOL_GPL(imx_drm_encoder_add_possible_crtcs); int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder) { - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct imx_drm_crtc *imx_crtc; + struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc); - list_for_each_entry(imx_crtc, &imxdrm->crtc_list, list) - if (imx_crtc->crtc == encoder->crtc) - return imx_crtc->mux_id; - - return -EINVAL; + return imx_crtc ? imx_crtc->mux_id : -EINVAL; } EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id); @@ -854,7 +844,6 @@ static int __init imx_drm_init(void) return -ENOMEM; mutex_init(&imx_drm_device->mutex); - INIT_LIST_HEAD(&imx_drm_device->crtc_list); INIT_LIST_HEAD(&imx_drm_device->connector_list); INIT_LIST_HEAD(&imx_drm_device->encoder_list); From baa68c4bfd9f85ada2d7bb3416f76561a84f1a0e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 9 Nov 2013 11:20:55 +0000 Subject: [PATCH 0413/1375] imx-drm: provide common connector mode validation function Provide a common connector mode validation function, which can be used to limit the available modes according to other components in the system. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 7 +++++++ drivers/staging/imx-drm/imx-drm.h | 3 +++ drivers/staging/imx-drm/imx-hdmi.c | 9 +-------- drivers/staging/imx-drm/imx-ldb.c | 8 +------- drivers/staging/imx-drm/imx-tve.c | 5 +++++ drivers/staging/imx-drm/parallel-display.c | 8 +------- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index c5268847a54e..7f14ed040072 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -211,6 +211,13 @@ static const struct file_operations imx_drm_driver_fops = { .llseek = noop_llseek, }; +int imx_drm_connector_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode) +{ + return MODE_OK; +} +EXPORT_SYMBOL(imx_drm_connector_mode_valid); + static struct imx_drm_device *imx_drm_device; static struct imx_drm_device *__imx_drm_device(void) diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index 5649f180dc44..4eb594ce9cff 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -68,4 +68,7 @@ int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder); int imx_drm_encoder_add_possible_crtcs(struct imx_drm_encoder *imx_drm_encoder, struct device_node *np); +int imx_drm_connector_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode); + #endif /* _IMX_DRM_H_ */ diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index a90f08d52ee7..4b690459f3bb 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -1406,13 +1406,6 @@ static int imx_hdmi_connector_get_modes(struct drm_connector *connector) return 0; } -static int imx_hdmi_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - - return MODE_OK; -} - static struct drm_encoder *imx_hdmi_connector_best_encoder(struct drm_connector *connector) { @@ -1501,7 +1494,7 @@ static struct drm_connector_funcs imx_hdmi_connector_funcs = { static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = { .get_modes = imx_hdmi_connector_get_modes, - .mode_valid = imx_hdmi_connector_mode_valid, + .mode_valid = imx_drm_connector_mode_valid, .best_encoder = imx_hdmi_connector_best_encoder, }; diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index 4aa47ae2a3ca..c6ec1e9e95cc 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -120,12 +120,6 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector) return num_modes; } -static int imx_ldb_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - return 0; -} - static struct drm_encoder *imx_ldb_connector_best_encoder( struct drm_connector *connector) { @@ -329,7 +323,7 @@ static struct drm_connector_funcs imx_ldb_connector_funcs = { static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = { .get_modes = imx_ldb_connector_get_modes, .best_encoder = imx_ldb_connector_best_encoder, - .mode_valid = imx_ldb_connector_mode_valid, + .mode_valid = imx_drm_connector_mode_valid, }; static struct drm_encoder_funcs imx_ldb_encoder_funcs = { diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 9abc7ca8b6cf..2d4e0973a02a 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -254,6 +254,11 @@ static int imx_tve_connector_mode_valid(struct drm_connector *connector, { struct imx_tve *tve = con_to_tve(connector); unsigned long rate; + int ret; + + ret = imx_drm_connector_mode_valid(connector, mode); + if (ret != MODE_OK) + return ret; /* pixel clock with 2x oversampling */ rate = clk_round_rate(tve->clk, 2000UL * mode->clock) / 2000; diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 351d61dede00..18a3e8aae22a 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -85,12 +85,6 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) return num_modes; } -static int imx_pd_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - return 0; -} - static struct drm_encoder *imx_pd_connector_best_encoder( struct drm_connector *connector) { @@ -147,7 +141,7 @@ static struct drm_connector_funcs imx_pd_connector_funcs = { static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = { .get_modes = imx_pd_connector_get_modes, .best_encoder = imx_pd_connector_best_encoder, - .mode_valid = imx_pd_connector_mode_valid, + .mode_valid = imx_drm_connector_mode_valid, }; static struct drm_encoder_funcs imx_pd_encoder_funcs = { From f2d66aad1aade34df678177c5ccb58feaea72156 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 15:52:16 +0000 Subject: [PATCH 0414/1375] imx-drm: simplify setup of panel format The encoder format passed into imx_drm_crtc_panel_format*() is the encoder format used for DRM in most cases; the HDMI encoder sets this to none, but this is incorrect, it should be TMDS. Since this is the case, we can pass the drm_encoder structure directly into this function and use the supplied fields there to configure the CRTC. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 18 ++++++++---------- drivers/staging/imx-drm/imx-drm.h | 4 ++-- drivers/staging/imx-drm/imx-hdmi.c | 3 +-- drivers/staging/imx-drm/imx-ldb.c | 3 +-- drivers/staging/imx-drm/imx-tve.c | 12 +++++++----- drivers/staging/imx-drm/ipuv3-crtc.c | 1 + drivers/staging/imx-drm/parallel-display.c | 3 +-- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 7f14ed040072..d9786eca3a36 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -111,32 +111,30 @@ struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc) return NULL; } -int imx_drm_crtc_panel_format_pins(struct drm_crtc *crtc, u32 encoder_type, +int imx_drm_panel_format_pins(struct drm_encoder *encoder, u32 interface_pix_fmt, int hsync_pin, int vsync_pin) { struct imx_drm_crtc_helper_funcs *helper; struct imx_drm_crtc *imx_crtc; - imx_crtc = imx_drm_find_crtc(crtc); + imx_crtc = imx_drm_find_crtc(encoder->crtc); if (!imx_crtc) return -EINVAL; helper = &imx_crtc->imx_drm_helper_funcs; if (helper->set_interface_pix_fmt) - return helper->set_interface_pix_fmt(crtc, - encoder_type, interface_pix_fmt, + return helper->set_interface_pix_fmt(encoder->crtc, + encoder->encoder_type, interface_pix_fmt, hsync_pin, vsync_pin); return 0; } -EXPORT_SYMBOL_GPL(imx_drm_crtc_panel_format_pins); +EXPORT_SYMBOL_GPL(imx_drm_panel_format_pins); -int imx_drm_crtc_panel_format(struct drm_crtc *crtc, u32 encoder_type, - u32 interface_pix_fmt) +int imx_drm_panel_format(struct drm_encoder *encoder, u32 interface_pix_fmt) { - return imx_drm_crtc_panel_format_pins(crtc, encoder_type, - interface_pix_fmt, 2, 3); + return imx_drm_panel_format_pins(encoder, interface_pix_fmt, 2, 3); } -EXPORT_SYMBOL_GPL(imx_drm_crtc_panel_format); +EXPORT_SYMBOL_GPL(imx_drm_panel_format); int imx_drm_crtc_vblank_get(struct imx_drm_crtc *imx_drm_crtc) { diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index 4eb594ce9cff..e3ca0c6b6a39 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -56,9 +56,9 @@ struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb); struct drm_device *imx_drm_device_get(void); void imx_drm_device_put(void); -int imx_drm_crtc_panel_format_pins(struct drm_crtc *crtc, u32 encoder_type, +int imx_drm_panel_format_pins(struct drm_encoder *encoder, u32 interface_pix_fmt, int hsync_pin, int vsync_pin); -int imx_drm_crtc_panel_format(struct drm_crtc *crtc, u32 encoder_type, +int imx_drm_panel_format(struct drm_encoder *encoder, u32 interface_pix_fmt); void imx_drm_fb_helper_set(struct drm_fbdev_cma *fbdev_helper); diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 4b690459f3bb..50475e606849 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -1453,8 +1453,7 @@ static void imx_hdmi_encoder_prepare(struct drm_encoder *encoder) struct imx_hdmi *hdmi = container_of(encoder, struct imx_hdmi, encoder); imx_hdmi_poweroff(hdmi); - imx_drm_crtc_panel_format(encoder->crtc, DRM_MODE_ENCODER_NONE, - V4L2_PIX_FMT_RGB24); + imx_drm_panel_format(encoder, V4L2_PIX_FMT_RGB24); } static void imx_hdmi_encoder_commit(struct drm_encoder *encoder) diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index c6ec1e9e95cc..dd29a4aad376 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -200,8 +200,7 @@ static void imx_ldb_encoder_prepare(struct drm_encoder *encoder) pixel_fmt = V4L2_PIX_FMT_RGB24; } - imx_drm_crtc_panel_format(encoder->crtc, DRM_MODE_ENCODER_LVDS, - pixel_fmt); + imx_drm_panel_format(encoder, pixel_fmt); } static void imx_ldb_encoder_commit(struct drm_encoder *encoder) diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 2d4e0973a02a..77131e5770f3 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -310,13 +310,11 @@ static void imx_tve_encoder_prepare(struct drm_encoder *encoder) switch (tve->mode) { case TVE_MODE_VGA: - imx_drm_crtc_panel_format_pins(encoder->crtc, - DRM_MODE_ENCODER_DAC, IPU_PIX_FMT_GBR24, + imx_drm_panel_format_pins(encoder, IPU_PIX_FMT_GBR24, tve->hsync_pin, tve->vsync_pin); break; case TVE_MODE_TVOUT: - imx_drm_crtc_panel_format(encoder->crtc, DRM_MODE_ENCODER_TVDAC, - V4L2_PIX_FMT_YUV444); + imx_drm_panel_format(encoder, V4L2_PIX_FMT_YUV444); break; } } @@ -510,12 +508,16 @@ static int tve_clk_init(struct imx_tve *tve, void __iomem *base) static int imx_tve_register(struct imx_tve *tve) { + int encoder_type; int ret; + encoder_type = tve->mode == TVE_MODE_VGA ? + DRM_MODE_ENCODER_DAC : DRM_MODE_ENCODER_TVDAC; + tve->connector.funcs = &imx_tve_connector_funcs; tve->encoder.funcs = &imx_tve_encoder_funcs; - tve->encoder.encoder_type = DRM_MODE_ENCODER_NONE; + tve->encoder.encoder_type = encoder_type; tve->connector.connector_type = DRM_MODE_CONNECTOR_VGA; drm_encoder_helper_add(&tve->encoder, &imx_tve_encoder_helper_funcs); diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 22be104fbda9..08e0a3b29174 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -284,6 +284,7 @@ static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc, u32 encoder_type, ipu_crtc->di_clkflags = IPU_DI_CLKMODE_SYNC | IPU_DI_CLKMODE_EXT; break; + case DRM_MODE_ENCODER_TMDS: case DRM_MODE_ENCODER_NONE: ipu_crtc->di_clkflags = 0; break; diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 18a3e8aae22a..12bcf4f58bdf 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -108,8 +108,7 @@ static void imx_pd_encoder_prepare(struct drm_encoder *encoder) { struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); - imx_drm_crtc_panel_format(encoder->crtc, DRM_MODE_ENCODER_NONE, - imxpd->interface_pix_fmt); + imx_drm_panel_format(encoder, imxpd->interface_pix_fmt); } static void imx_pd_encoder_commit(struct drm_encoder *encoder) From 17b5001b5143e3b7fce1c584bdcffd726dd8667c Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 11:23:34 +0000 Subject: [PATCH 0415/1375] imx-drm: convert to componentised device support Use the componentised device support for imx-drm. This requires all the sub-components and the master device to register with the component device support. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- arch/arm/boot/dts/imx51-babbage.dts | 10 +- arch/arm/boot/dts/imx53-m53evk.dts | 8 +- arch/arm/boot/dts/imx53-mba53.dts | 6 ++ arch/arm/boot/dts/imx53-qsb.dts | 8 +- arch/arm/boot/dts/imx6q-sabresd.dts | 4 + arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 6 ++ drivers/staging/imx-drm/imx-drm-core.c | 105 +++++++++++++++++---- drivers/staging/imx-drm/imx-hdmi.c | 41 +++++--- drivers/staging/imx-drm/imx-ldb.c | 40 +++++--- drivers/staging/imx-drm/imx-tve.c | 63 ++++++++----- drivers/staging/imx-drm/ipuv3-crtc.c | 64 ++++++++----- drivers/staging/imx-drm/parallel-display.c | 30 ++++-- 12 files changed, 284 insertions(+), 101 deletions(-) diff --git a/arch/arm/boot/dts/imx51-babbage.dts b/arch/arm/boot/dts/imx51-babbage.dts index be1407cf5abd..6ff15a0eacb3 100644 --- a/arch/arm/boot/dts/imx51-babbage.dts +++ b/arch/arm/boot/dts/imx51-babbage.dts @@ -21,7 +21,7 @@ reg = <0x90000000 0x20000000>; }; - display@di0 { + display0: display@di0 { compatible = "fsl,imx-parallel-display"; crtcs = <&ipu 0>; interface-pix-fmt = "rgb24"; @@ -43,7 +43,7 @@ }; }; - display@di1 { + display1: display@di1 { compatible = "fsl,imx-parallel-display"; crtcs = <&ipu 1>; interface-pix-fmt = "rgb565"; @@ -81,6 +81,12 @@ }; }; + imx-drm { + compatible = "fsl,imx-drm"; + crtcs = <&ipu 0>, <&ipu 1>; + connectors = <&display0>, <&display1>; + }; + sound { compatible = "fsl,imx51-babbage-sgtl5000", "fsl,imx-audio-sgtl5000"; diff --git a/arch/arm/boot/dts/imx53-m53evk.dts b/arch/arm/boot/dts/imx53-m53evk.dts index 7d304d02ed38..ee6107b6484c 100644 --- a/arch/arm/boot/dts/imx53-m53evk.dts +++ b/arch/arm/boot/dts/imx53-m53evk.dts @@ -21,7 +21,7 @@ }; soc { - display@di1 { + display1: display@di1 { compatible = "fsl,imx-parallel-display"; crtcs = <&ipu 1>; interface-pix-fmt = "bgr666"; @@ -53,6 +53,12 @@ default-brightness-level = <6>; }; + imx-drm { + compatible = "fsl,imx-drm"; + crtcs = <&ipu 1>; + connectors = <&display1>; + }; + leds { compatible = "gpio-leds"; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/imx53-mba53.dts b/arch/arm/boot/dts/imx53-mba53.dts index a63090267941..9b6e76980a74 100644 --- a/arch/arm/boot/dts/imx53-mba53.dts +++ b/arch/arm/boot/dts/imx53-mba53.dts @@ -43,6 +43,12 @@ status = "disabled"; }; + imx-drm { + compatible = "fsl,imx-drm"; + crtcs = <&ipu 1>; + connectors = <&disp1>, <&tve>; + }; + reg_3p2v: 3p2v { compatible = "regulator-fixed"; regulator-name = "3P2V"; diff --git a/arch/arm/boot/dts/imx53-qsb.dts b/arch/arm/boot/dts/imx53-qsb.dts index 91a5935a4aac..3cb4f7791a91 100644 --- a/arch/arm/boot/dts/imx53-qsb.dts +++ b/arch/arm/boot/dts/imx53-qsb.dts @@ -21,7 +21,7 @@ reg = <0x70000000 0x40000000>; }; - display@di0 { + display0: display@di0 { compatible = "fsl,imx-parallel-display"; crtcs = <&ipu 0>; interface-pix-fmt = "rgb565"; @@ -72,6 +72,12 @@ }; }; + imx-drm { + compatible = "fsl,imx-drm"; + crtcs = <&ipu 0>; + connectors = <&display0>; + }; + leds { compatible = "gpio-leds"; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/imx6q-sabresd.dts b/arch/arm/boot/dts/imx6q-sabresd.dts index 9cbdfe7a0931..66f220a82e45 100644 --- a/arch/arm/boot/dts/imx6q-sabresd.dts +++ b/arch/arm/boot/dts/imx6q-sabresd.dts @@ -20,6 +20,10 @@ compatible = "fsl,imx6q-sabresd", "fsl,imx6q"; }; +&imx_drm { + crtcs = <&ipu1 0>, <&ipu1 1>, <&ipu2 0>, <&ipu2 1>; +}; + &sata { status = "okay"; }; diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi index e75e11b36dff..dfca3e001398 100644 --- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi @@ -62,6 +62,12 @@ }; }; + imx_drm: imx-drm { + compatible = "fsl,imx-drm"; + crtcs = <&ipu1 0>, <&ipu1 1>; + connectors = <&ldb>; + }; + sound { compatible = "fsl,imx6q-sabresd-wm8962", "fsl,imx-audio-wm8962"; diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index d9786eca3a36..82b0337096b0 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * */ - +#include #include #include #include @@ -90,6 +90,8 @@ static int imx_drm_driver_unload(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; + component_unbind_all(drm->dev, drm); + imx_drm_device_put(); drm_vblank_cleanup(drm); @@ -371,11 +373,8 @@ static void imx_drm_connector_unregister( } /* - * Called by the CRTC driver when all CRTCs are registered. This - * puts all the pieces together and initializes the driver. - * Once this is called no more CRTCs can be registered since - * the drm core has hardcoded the number of crtcs in several - * places. + * Main DRM initialisation. This binds, initialises and registers + * with DRM the subcomponents of the driver. */ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) { @@ -428,8 +427,15 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) platform_set_drvdata(drm->platformdev, drm); mutex_unlock(&imxdrm->mutex); + + /* Now try and bind all our sub-components */ + ret = component_bind_all(drm->dev, drm); + if (ret) + goto err_relock; return 0; +err_relock: + mutex_lock(&imxdrm->mutex); err_vblank: drm_vblank_cleanup(drm); err_kms: @@ -809,6 +815,70 @@ static struct drm_driver imx_drm_driver = { .patchlevel = 0, }; +static int compare_parent_of(struct device *dev, void *data) +{ + struct of_phandle_args *args = data; + return dev->parent && dev->parent->of_node == args->np; +} + +static int compare_of(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +static int imx_drm_add_components(struct device *master, struct master *m) +{ + struct device_node *np = master->of_node; + unsigned i; + int ret; + + for (i = 0; ; i++) { + struct of_phandle_args args; + + ret = of_parse_phandle_with_fixed_args(np, "crtcs", 1, + i, &args); + if (ret) + break; + + ret = component_master_add_child(m, compare_parent_of, &args); + of_node_put(args.np); + + if (ret) + return ret; + } + + for (i = 0; ; i++) { + struct device_node *node; + + node = of_parse_phandle(np, "connectors", i); + if (!node) + break; + + ret = component_master_add_child(m, compare_of, node); + of_node_put(node); + + if (ret) + return ret; + } + return 0; +} + +static int imx_drm_bind(struct device *dev) +{ + return drm_platform_init(&imx_drm_driver, to_platform_device(dev)); +} + +static void imx_drm_unbind(struct device *dev) +{ + drm_put_dev(dev_get_drvdata(dev)); +} + +static const struct component_master_ops imx_drm_ops = { + .add_components = imx_drm_add_components, + .bind = imx_drm_bind, + .unbind = imx_drm_unbind, +}; + static int imx_drm_platform_probe(struct platform_device *pdev) { int ret; @@ -819,27 +889,31 @@ static int imx_drm_platform_probe(struct platform_device *pdev) imx_drm_device->dev = &pdev->dev; - return drm_platform_init(&imx_drm_driver, pdev); + return component_master_add(&pdev->dev, &imx_drm_ops); } static int imx_drm_platform_remove(struct platform_device *pdev) { - drm_put_dev(platform_get_drvdata(pdev)); - + component_master_del(&pdev->dev, &imx_drm_ops); return 0; } +static const struct of_device_id imx_drm_dt_ids[] = { + { .compatible = "fsl,imx-drm", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, imx_drm_dt_ids); + static struct platform_driver imx_drm_pdrv = { .probe = imx_drm_platform_probe, .remove = imx_drm_platform_remove, .driver = { .owner = THIS_MODULE, .name = "imx-drm", + .of_match_table = imx_drm_dt_ids, }, }; -static struct platform_device *imx_drm_pdev; - static int __init imx_drm_init(void) { int ret; @@ -852,12 +926,6 @@ static int __init imx_drm_init(void) INIT_LIST_HEAD(&imx_drm_device->connector_list); INIT_LIST_HEAD(&imx_drm_device->encoder_list); - imx_drm_pdev = platform_device_register_simple("imx-drm", -1, NULL, 0); - if (IS_ERR(imx_drm_pdev)) { - ret = PTR_ERR(imx_drm_pdev); - goto err_pdev; - } - ret = platform_driver_register(&imx_drm_pdrv); if (ret) goto err_pdrv; @@ -865,8 +933,6 @@ static int __init imx_drm_init(void) return 0; err_pdrv: - platform_device_unregister(imx_drm_pdev); -err_pdev: kfree(imx_drm_device); return ret; @@ -874,7 +940,6 @@ err_pdev: static void __exit imx_drm_exit(void) { - platform_device_unregister(imx_drm_pdev); platform_driver_unregister(&imx_drm_pdrv); kfree(imx_drm_device); diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 50475e606849..14b4a4b976b9 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -12,6 +12,7 @@ * Copyright (C) 2010, Guennadi Liakhovetski */ +#include #include #include #include @@ -1582,21 +1583,22 @@ static const struct of_device_id imx_hdmi_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, imx_hdmi_dt_ids); -static int imx_hdmi_platform_probe(struct platform_device *pdev) +static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) { + struct platform_device *pdev = to_platform_device(dev); const struct of_device_id *of_id = - of_match_device(imx_hdmi_dt_ids, &pdev->dev); - struct device_node *np = pdev->dev.of_node; + of_match_device(imx_hdmi_dt_ids, dev); + struct device_node *np = dev->of_node; struct device_node *ddc_node; struct imx_hdmi *hdmi; struct resource *iores; int ret, irq; - hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); + hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); if (!hdmi) return -ENOMEM; - hdmi->dev = &pdev->dev; + hdmi->dev = dev; hdmi->sample_rate = 48000; hdmi->ratio = 100; @@ -1620,13 +1622,13 @@ static int imx_hdmi_platform_probe(struct platform_device *pdev) if (irq < 0) return -EINVAL; - ret = devm_request_irq(&pdev->dev, irq, imx_hdmi_irq, 0, - dev_name(&pdev->dev), hdmi); + ret = devm_request_irq(dev, irq, imx_hdmi_irq, 0, + dev_name(dev), hdmi); if (ret) return ret; iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hdmi->regs = devm_ioremap_resource(&pdev->dev, iores); + hdmi->regs = devm_ioremap_resource(dev, iores); if (IS_ERR(hdmi->regs)) return PTR_ERR(hdmi->regs); @@ -1665,7 +1667,7 @@ static int imx_hdmi_platform_probe(struct platform_device *pdev) } /* Product and revision IDs */ - dev_info(&pdev->dev, + dev_info(dev, "Detected HDMI controller 0x%x:0x%x:0x%x:0x%x\n", hdmi_readb(hdmi, HDMI_DESIGN_ID), hdmi_readb(hdmi, HDMI_REVISION_ID), @@ -1699,7 +1701,7 @@ static int imx_hdmi_platform_probe(struct platform_device *pdev) imx_drm_encoder_add_possible_crtcs(hdmi->imx_drm_encoder, np); - platform_set_drvdata(pdev, hdmi); + dev_set_drvdata(dev, hdmi); return 0; @@ -1711,9 +1713,10 @@ err_isfr: return ret; } -static int imx_hdmi_platform_remove(struct platform_device *pdev) +static void imx_hdmi_unbind(struct device *dev, struct device *master, + void *data) { - struct imx_hdmi *hdmi = platform_get_drvdata(pdev); + struct imx_hdmi *hdmi = dev_get_drvdata(dev); struct drm_connector *connector = &hdmi->connector; struct drm_encoder *encoder = &hdmi->encoder; @@ -1724,7 +1727,21 @@ static int imx_hdmi_platform_remove(struct platform_device *pdev) clk_disable_unprepare(hdmi->iahb_clk); clk_disable_unprepare(hdmi->isfr_clk); i2c_put_adapter(hdmi->ddc); +} +static const struct component_ops hdmi_ops = { + .bind = imx_hdmi_bind, + .unbind = imx_hdmi_unbind, +}; + +static int imx_hdmi_platform_probe(struct platform_device *pdev) +{ + return component_add(&pdev->dev, &hdmi_ops); +} + +static int imx_hdmi_platform_remove(struct platform_device *pdev) +{ + component_del(&pdev->dev, &hdmi_ops); return 0; } diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index dd29a4aad376..d00f93f3440d 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -450,11 +451,11 @@ static const struct of_device_id imx_ldb_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids); -static int imx_ldb_probe(struct platform_device *pdev) +static int imx_ldb_bind(struct device *dev, struct device *master, void *data) { - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; const struct of_device_id *of_id = - of_match_device(imx_ldb_dt_ids, &pdev->dev); + of_match_device(imx_ldb_dt_ids, dev); struct device_node *child; const u8 *edidp; struct imx_ldb *imx_ldb; @@ -464,17 +465,17 @@ static int imx_ldb_probe(struct platform_device *pdev) int ret; int i; - imx_ldb = devm_kzalloc(&pdev->dev, sizeof(*imx_ldb), GFP_KERNEL); + imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL); if (!imx_ldb) return -ENOMEM; imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr"); if (IS_ERR(imx_ldb->regmap)) { - dev_err(&pdev->dev, "failed to get parent regmap\n"); + dev_err(dev, "failed to get parent regmap\n"); return PTR_ERR(imx_ldb->regmap); } - imx_ldb->dev = &pdev->dev; + imx_ldb->dev = dev; if (of_id) imx_ldb->lvds_mux = of_id->data; @@ -512,7 +513,7 @@ static int imx_ldb_probe(struct platform_device *pdev) return -EINVAL; if (dual && i > 0) { - dev_warn(&pdev->dev, "dual-channel mode, ignoring second output\n"); + dev_warn(dev, "dual-channel mode, ignoring second output\n"); continue; } @@ -551,7 +552,7 @@ static int imx_ldb_probe(struct platform_device *pdev) break; case LVDS_BIT_MAP_JEIDA: if (datawidth == 18) { - dev_err(&pdev->dev, "JEIDA standard only supported in 24 bit\n"); + dev_err(dev, "JEIDA standard only supported in 24 bit\n"); return -EINVAL; } if (i == 0 || dual) @@ -560,7 +561,7 @@ static int imx_ldb_probe(struct platform_device *pdev) imx_ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 | LDB_BIT_MAP_CH1_JEIDA; break; default: - dev_err(&pdev->dev, "data mapping not specified or invalid\n"); + dev_err(dev, "data mapping not specified or invalid\n"); return -EINVAL; } @@ -571,14 +572,15 @@ static int imx_ldb_probe(struct platform_device *pdev) imx_drm_encoder_add_possible_crtcs(channel->imx_drm_encoder, child); } - platform_set_drvdata(pdev, imx_ldb); + dev_set_drvdata(dev, imx_ldb); return 0; } -static int imx_ldb_remove(struct platform_device *pdev) +static void imx_ldb_unbind(struct device *dev, struct device *master, + void *data) { - struct imx_ldb *imx_ldb = platform_get_drvdata(pdev); + struct imx_ldb *imx_ldb = dev_get_drvdata(dev); int i; for (i = 0; i < 2; i++) { @@ -591,7 +593,21 @@ static int imx_ldb_remove(struct platform_device *pdev) imx_drm_remove_connector(channel->imx_drm_connector); imx_drm_remove_encoder(channel->imx_drm_encoder); } +} +static const struct component_ops imx_ldb_ops = { + .bind = imx_ldb_bind, + .unbind = imx_ldb_unbind, +}; + +static int imx_ldb_probe(struct platform_device *pdev) +{ + return component_add(&pdev->dev, &imx_ldb_ops); +} + +static int imx_ldb_remove(struct platform_device *pdev) +{ + component_del(&pdev->dev, &imx_ldb_ops); return 0; } diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 77131e5770f3..ad840d78a09a 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -583,9 +584,10 @@ static const int of_get_tve_mode(struct device_node *np) return -EINVAL; } -static int imx_tve_probe(struct platform_device *pdev) +static int imx_tve_bind(struct device *dev, struct device *master, void *data) { - struct device_node *np = pdev->dev.of_node; + struct platform_device *pdev = to_platform_device(dev); + struct device_node *np = dev->of_node; struct device_node *ddc_node; struct imx_tve *tve; struct resource *res; @@ -594,11 +596,11 @@ static int imx_tve_probe(struct platform_device *pdev) int irq; int ret; - tve = devm_kzalloc(&pdev->dev, sizeof(*tve), GFP_KERNEL); + tve = devm_kzalloc(dev, sizeof(*tve), GFP_KERNEL); if (!tve) return -ENOMEM; - tve->dev = &pdev->dev; + tve->dev = dev; spin_lock_init(&tve->lock); ddc_node = of_parse_phandle(np, "ddc", 0); @@ -609,7 +611,7 @@ static int imx_tve_probe(struct platform_device *pdev) tve->mode = of_get_tve_mode(np); if (tve->mode != TVE_MODE_VGA) { - dev_err(&pdev->dev, "only VGA mode supported, currently\n"); + dev_err(dev, "only VGA mode supported, currently\n"); return -EINVAL; } @@ -618,7 +620,7 @@ static int imx_tve_probe(struct platform_device *pdev) &tve->hsync_pin); if (ret < 0) { - dev_err(&pdev->dev, "failed to get vsync pin\n"); + dev_err(dev, "failed to get vsync pin\n"); return ret; } @@ -626,40 +628,40 @@ static int imx_tve_probe(struct platform_device *pdev) &tve->vsync_pin); if (ret < 0) { - dev_err(&pdev->dev, "failed to get vsync pin\n"); + dev_err(dev, "failed to get vsync pin\n"); return ret; } } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); + base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return PTR_ERR(base); tve_regmap_config.lock_arg = tve; - tve->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "tve", base, + tve->regmap = devm_regmap_init_mmio_clk(dev, "tve", base, &tve_regmap_config); if (IS_ERR(tve->regmap)) { - dev_err(&pdev->dev, "failed to init regmap: %ld\n", + dev_err(dev, "failed to init regmap: %ld\n", PTR_ERR(tve->regmap)); return PTR_ERR(tve->regmap); } irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "failed to get irq\n"); + dev_err(dev, "failed to get irq\n"); return irq; } - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + ret = devm_request_threaded_irq(dev, irq, NULL, imx_tve_irq_handler, IRQF_ONESHOT, "imx-tve", tve); if (ret < 0) { - dev_err(&pdev->dev, "failed to request irq: %d\n", ret); + dev_err(dev, "failed to request irq: %d\n", ret); return ret; } - tve->dac_reg = devm_regulator_get(&pdev->dev, "dac"); + tve->dac_reg = devm_regulator_get(dev, "dac"); if (!IS_ERR(tve->dac_reg)) { regulator_set_voltage(tve->dac_reg, 2750000, 2750000); ret = regulator_enable(tve->dac_reg); @@ -667,17 +669,17 @@ static int imx_tve_probe(struct platform_device *pdev) return ret; } - tve->clk = devm_clk_get(&pdev->dev, "tve"); + tve->clk = devm_clk_get(dev, "tve"); if (IS_ERR(tve->clk)) { - dev_err(&pdev->dev, "failed to get high speed tve clock: %ld\n", + dev_err(dev, "failed to get high speed tve clock: %ld\n", PTR_ERR(tve->clk)); return PTR_ERR(tve->clk); } /* this is the IPU DI clock input selector, can be parented to tve_di */ - tve->di_sel_clk = devm_clk_get(&pdev->dev, "di_sel"); + tve->di_sel_clk = devm_clk_get(dev, "di_sel"); if (IS_ERR(tve->di_sel_clk)) { - dev_err(&pdev->dev, "failed to get ipu di mux clock: %ld\n", + dev_err(dev, "failed to get ipu di mux clock: %ld\n", PTR_ERR(tve->di_sel_clk)); return PTR_ERR(tve->di_sel_clk); } @@ -688,11 +690,11 @@ static int imx_tve_probe(struct platform_device *pdev) ret = regmap_read(tve->regmap, TVE_COM_CONF_REG, &val); if (ret < 0) { - dev_err(&pdev->dev, "failed to read configuration register: %d\n", ret); + dev_err(dev, "failed to read configuration register: %d\n", ret); return ret; } if (val != 0x00100000) { - dev_err(&pdev->dev, "configuration register default value indicates this is not a TVEv2\n"); + dev_err(dev, "configuration register default value indicates this is not a TVEv2\n"); return -ENODEV; } @@ -705,14 +707,15 @@ static int imx_tve_probe(struct platform_device *pdev) ret = imx_drm_encoder_add_possible_crtcs(tve->imx_drm_encoder, np); - platform_set_drvdata(pdev, tve); + dev_set_drvdata(dev, tve); return 0; } -static int imx_tve_remove(struct platform_device *pdev) +static void imx_tve_unbind(struct device *dev, struct device *master, + void *data) { - struct imx_tve *tve = platform_get_drvdata(pdev); + struct imx_tve *tve = dev_get_drvdata(dev); struct drm_connector *connector = &tve->connector; struct drm_encoder *encoder = &tve->encoder; @@ -723,7 +726,21 @@ static int imx_tve_remove(struct platform_device *pdev) if (!IS_ERR(tve->dac_reg)) regulator_disable(tve->dac_reg); +} +static const struct component_ops imx_tve_ops = { + .bind = imx_tve_bind, + .unbind = imx_tve_unbind, +}; + +static int imx_tve_probe(struct platform_device *pdev) +{ + return component_add(&pdev->dev, &imx_tve_ops); +} + +static int imx_tve_remove(struct platform_device *pdev) +{ + component_del(&pdev->dev, &imx_tve_ops); return 0; } diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 08e0a3b29174..d779ad2d1f4e 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ +#include #include #include #include @@ -400,43 +401,60 @@ err_put_resources: return ret; } -static int ipu_drm_probe(struct platform_device *pdev) +static int ipu_drm_bind(struct device *dev, struct device *master, void *data) { - struct ipu_client_platformdata *pdata = pdev->dev.platform_data; + struct ipu_client_platformdata *pdata = dev->platform_data; struct ipu_crtc *ipu_crtc; int ret; - if (!pdata) + ipu_crtc = devm_kzalloc(dev, sizeof(*ipu_crtc), GFP_KERNEL); + if (!ipu_crtc) + return -ENOMEM; + + ipu_crtc->dev = dev; + + ret = ipu_crtc_init(ipu_crtc, pdata); + if (ret) + return ret; + + dev_set_drvdata(dev, ipu_crtc); + + return 0; +} + +static void ipu_drm_unbind(struct device *dev, struct device *master, + void *data) +{ + struct ipu_crtc *ipu_crtc = dev_get_drvdata(dev); + + imx_drm_remove_crtc(ipu_crtc->imx_crtc); + + ipu_plane_put_resources(ipu_crtc->plane[0]); + ipu_put_resources(ipu_crtc); +} + +static const struct component_ops ipu_crtc_ops = { + .bind = ipu_drm_bind, + .unbind = ipu_drm_unbind, +}; + +static int ipu_drm_probe(struct platform_device *pdev) +{ + int ret; + + if (!pdev->dev.platform_data) return -EINVAL; ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (ret) return ret; - ipu_crtc = devm_kzalloc(&pdev->dev, sizeof(*ipu_crtc), GFP_KERNEL); - if (!ipu_crtc) - return -ENOMEM; - - ipu_crtc->dev = &pdev->dev; - - ret = ipu_crtc_init(ipu_crtc, pdata); - if (ret) - return ret; - - platform_set_drvdata(pdev, ipu_crtc); - - return 0; + return component_add(&pdev->dev, &ipu_crtc_ops); } static int ipu_drm_remove(struct platform_device *pdev) { - struct ipu_crtc *ipu_crtc = platform_get_drvdata(pdev); - - imx_drm_remove_crtc(ipu_crtc->imx_crtc); - - ipu_plane_put_resources(ipu_crtc->plane[0]); - ipu_put_resources(ipu_crtc); - + component_del(&pdev->dev, &ipu_crtc_ops); return 0; } diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 12bcf4f58bdf..4019cae35ff9 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -18,6 +18,7 @@ * MA 02110-1301, USA. */ +#include #include #include #include @@ -192,15 +193,15 @@ static int imx_pd_register(struct imx_parallel_display *imxpd) return 0; } -static int imx_pd_probe(struct platform_device *pdev) +static int imx_pd_bind(struct device *dev, struct device *master, void *data) { - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; const u8 *edidp; struct imx_parallel_display *imxpd; int ret; const char *fmt; - imxpd = devm_kzalloc(&pdev->dev, sizeof(*imxpd), GFP_KERNEL); + imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL); if (!imxpd) return -ENOMEM; @@ -218,7 +219,7 @@ static int imx_pd_probe(struct platform_device *pdev) imxpd->interface_pix_fmt = V4L2_PIX_FMT_BGR666; } - imxpd->dev = &pdev->dev; + imxpd->dev = dev; ret = imx_pd_register(imxpd); if (ret) @@ -226,14 +227,15 @@ static int imx_pd_probe(struct platform_device *pdev) ret = imx_drm_encoder_add_possible_crtcs(imxpd->imx_drm_encoder, np); - platform_set_drvdata(pdev, imxpd); + dev_set_drvdata(dev, imxpd); return 0; } -static int imx_pd_remove(struct platform_device *pdev) +static void imx_pd_unbind(struct device *dev, struct device *master, + void *data) { - struct imx_parallel_display *imxpd = platform_get_drvdata(pdev); + struct imx_parallel_display *imxpd = dev_get_drvdata(dev); struct drm_connector *connector = &imxpd->connector; struct drm_encoder *encoder = &imxpd->encoder; @@ -241,7 +243,21 @@ static int imx_pd_remove(struct platform_device *pdev) imx_drm_remove_connector(imxpd->imx_drm_connector); imx_drm_remove_encoder(imxpd->imx_drm_encoder); +} +static const struct component_ops imx_pd_ops = { + .bind = imx_pd_bind, + .unbind = imx_pd_unbind, +}; + +static int imx_pd_probe(struct platform_device *pdev) +{ + return component_add(&pdev->dev, &imx_pd_ops); +} + +static int imx_pd_remove(struct platform_device *pdev) +{ + component_del(&pdev->dev, &imx_pd_ops); return 0; } From e355e7dd607bd0338ba1899fc35136cbe2ea13f2 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 18:39:29 +0000 Subject: [PATCH 0416/1375] imx-drm: delay publishing sysfs connector entries Delay publishing sysfs connector entries until all components have initialised. This reduces the probability of generating false hotplug events when we're uncertain whether the driver can fully initialise. This also pulls that code out of the individual imx-drm connector drivers. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 82b0337096b0..3cd330e646f7 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -355,7 +355,7 @@ static int imx_drm_connector_register( imx_drm_connector->connector->connector_type); drm_mode_group_reinit(imxdrm->drm); - return drm_sysfs_connector_add(imx_drm_connector->connector); + return 0; } /* @@ -379,6 +379,7 @@ static void imx_drm_connector_unregister( static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) { struct imx_drm_device *imxdrm = __imx_drm_device(); + struct drm_connector *connector; int ret; imxdrm->drm = drm; @@ -432,8 +433,27 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) ret = component_bind_all(drm->dev, drm); if (ret) goto err_relock; + + /* + * All components are now added, we can publish the connector sysfs + * entries to userspace. This will generate hotplug events and so + * userspace will expect to be able to access DRM at this point. + */ + list_for_each_entry(connector, &drm->mode_config.connector_list, head) { + ret = drm_sysfs_connector_add(connector); + if (ret) { + dev_err(drm->dev, + "[CONNECTOR:%d:%s] drm_sysfs_connector_add failed: %d\n", + connector->base.id, + drm_get_connector_name(connector), ret); + goto err_unbind; + } + } + return 0; +err_unbind: + component_unbind_all(drm->dev, drm); err_relock: mutex_lock(&imxdrm->mutex); err_vblank: From 8acba02f7e8538a54d4bf3ed8a2d3b31dd5eca45 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 12:13:47 +0000 Subject: [PATCH 0417/1375] imx-drm: remove separate imx-fbdev Now that we know when the components of the imx-drm subsystem will be initialised, we can move the fbdev helper initialisation and teardown into imx-drm-core. This gives us the required ordering that DRM wants in both driver load and unload methods. We can also stop exporting the imx_drm_device_get() and imx_drm_device_put() methods; nothing but the fbdev helper was making use of these. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/Makefile | 1 - drivers/staging/imx-drm/imx-drm-core.c | 43 ++++++++++----- drivers/staging/imx-drm/imx-drm.h | 3 -- drivers/staging/imx-drm/imx-fbdev.c | 74 -------------------------- 4 files changed, 31 insertions(+), 90 deletions(-) delete mode 100644 drivers/staging/imx-drm/imx-fbdev.c diff --git a/drivers/staging/imx-drm/Makefile b/drivers/staging/imx-drm/Makefile index 4677585b5ad5..5239f908ceec 100644 --- a/drivers/staging/imx-drm/Makefile +++ b/drivers/staging/imx-drm/Makefile @@ -6,7 +6,6 @@ obj-$(CONFIG_DRM_IMX) += imxdrm.o obj-$(CONFIG_DRM_IMX_PARALLEL_DISPLAY) += parallel-display.o obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o -obj-$(CONFIG_DRM_IMX_FB_HELPER) += imx-fbdev.o obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += ipu-v3/ imx-ipuv3-crtc-objs := ipuv3-crtc.o ipuv3-plane.o diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 3cd330e646f7..5a60886b3a6b 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -70,6 +70,10 @@ struct imx_drm_connector { struct module *owner; }; +static int legacyfb_depth = 16; +module_param(legacyfb_depth, int, 0444); + +static void imx_drm_device_put(void); static struct imx_drm_device *__imx_drm_device(void); int imx_drm_crtc_id(struct imx_drm_crtc *crtc) @@ -80,16 +84,23 @@ EXPORT_SYMBOL_GPL(imx_drm_crtc_id); static void imx_drm_driver_lastclose(struct drm_device *drm) { +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) struct imx_drm_device *imxdrm = drm->dev_private; if (imxdrm->fbhelper) drm_fbdev_cma_restore_mode(imxdrm->fbhelper); +#endif } static int imx_drm_driver_unload(struct drm_device *drm) { +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) struct imx_drm_device *imxdrm = drm->dev_private; + if (imxdrm->fbhelper) + drm_fbdev_cma_fini(imxdrm->fbhelper); +#endif + component_unbind_all(drm->dev, drm); imx_drm_device_put(); @@ -225,7 +236,7 @@ static struct imx_drm_device *__imx_drm_device(void) return imx_drm_device; } -struct drm_device *imx_drm_device_get(void) +static struct drm_device *imx_drm_device_get(void) { struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_encoder *enc; @@ -273,9 +284,8 @@ unwind_enc: return NULL; } -EXPORT_SYMBOL_GPL(imx_drm_device_get); -void imx_drm_device_put(void) +static void imx_drm_device_put(void) { struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_encoder *enc; @@ -295,7 +305,6 @@ void imx_drm_device_put(void) mutex_unlock(&imxdrm->mutex); } -EXPORT_SYMBOL_GPL(imx_drm_device_put); static int drm_mode_group_reinit(struct drm_device *dev) { @@ -450,6 +459,24 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) } } + /* + * All components are now initialised, so setup the fb helper. + * The fb helper takes copies of key hardware information, so the + * crtcs/connectors/encoders must not change after this point. + */ +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) + if (legacyfb_depth != 16 && legacyfb_depth != 32) { + dev_warn(drm->dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); + legacyfb_depth = 16; + } + imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth, + drm->mode_config.num_crtc, MAX_CRTC); + if (IS_ERR(imxdrm->fbhelper)) { + ret = PTR_ERR(imxdrm->fbhelper); + imxdrm->fbhelper = NULL; + goto err_unbind; + } +#endif return 0; err_unbind: @@ -767,14 +794,6 @@ err_busy: } EXPORT_SYMBOL_GPL(imx_drm_add_connector); -void imx_drm_fb_helper_set(struct drm_fbdev_cma *fbdev_helper) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - imxdrm->fbhelper = fbdev_helper; -} -EXPORT_SYMBOL_GPL(imx_drm_fb_helper_set); - /* * imx_drm_remove_connector - remove a connector */ diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index e3ca0c6b6a39..d1fb1146240e 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -54,13 +54,10 @@ void imx_drm_mode_config_init(struct drm_device *drm); struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb); -struct drm_device *imx_drm_device_get(void); -void imx_drm_device_put(void); int imx_drm_panel_format_pins(struct drm_encoder *encoder, u32 interface_pix_fmt, int hsync_pin, int vsync_pin); int imx_drm_panel_format(struct drm_encoder *encoder, u32 interface_pix_fmt); -void imx_drm_fb_helper_set(struct drm_fbdev_cma *fbdev_helper); struct device_node; diff --git a/drivers/staging/imx-drm/imx-fbdev.c b/drivers/staging/imx-drm/imx-fbdev.c deleted file mode 100644 index 8331739c3d08..000000000000 --- a/drivers/staging/imx-drm/imx-fbdev.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * i.MX drm driver - * - * Copyright (C) 2012 Sascha Hauer, Pengutronix - * - * Based on Samsung Exynos code - * - * Copyright (c) 2011 Samsung Electronics Co., 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. - * - */ -#include -#include -#include -#include -#include - -#include "imx-drm.h" - -#define MAX_CONNECTOR 4 -#define PREFERRED_BPP 16 - -static struct drm_fbdev_cma *fbdev_cma; - -static int legacyfb_depth = 16; - -module_param(legacyfb_depth, int, 0444); - -static int __init imx_fb_helper_init(void) -{ - struct drm_device *drm = imx_drm_device_get(); - - if (!drm) - return -EINVAL; - - if (legacyfb_depth != 16 && legacyfb_depth != 32) { - pr_warn("i.MX legacyfb: invalid legacyfb_depth setting. defaulting to 16bpp\n"); - legacyfb_depth = 16; - } - - fbdev_cma = drm_fbdev_cma_init(drm, legacyfb_depth, - drm->mode_config.num_crtc, MAX_CONNECTOR); - - if (IS_ERR(fbdev_cma)) { - imx_drm_device_put(); - return PTR_ERR(fbdev_cma); - } - - imx_drm_fb_helper_set(fbdev_cma); - - return 0; -} - -static void __exit imx_fb_helper_exit(void) -{ - imx_drm_fb_helper_set(NULL); - drm_fbdev_cma_fini(fbdev_cma); - imx_drm_device_put(); -} - -late_initcall(imx_fb_helper_init); -module_exit(imx_fb_helper_exit); - -MODULE_DESCRIPTION("Freescale i.MX legacy fb driver"); -MODULE_AUTHOR("Sascha Hauer, Pengutronix"); -MODULE_LICENSE("GPL"); From 1df8b5300001907cb1711f3526394f3ef3240123 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 16:04:48 +0000 Subject: [PATCH 0418/1375] imx-drm: remove imx-fb.c imx-fb.c doesn't need to be separate from imx-drm-core.c - all it is doing is setting up the minimum and maximum sizes of the scanout buffers, and setting up the mode_config function pointers. Move the contents into imx-drm-core.c and kill this file. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/Makefile | 2 +- drivers/staging/imx-drm/imx-drm-core.c | 16 ++++++++- drivers/staging/imx-drm/imx-fb.c | 47 -------------------------- 3 files changed, 16 insertions(+), 49 deletions(-) delete mode 100644 drivers/staging/imx-drm/imx-fb.c diff --git a/drivers/staging/imx-drm/Makefile b/drivers/staging/imx-drm/Makefile index 5239f908ceec..129e3a3f59f1 100644 --- a/drivers/staging/imx-drm/Makefile +++ b/drivers/staging/imx-drm/Makefile @@ -1,5 +1,5 @@ -imxdrm-objs := imx-drm-core.o imx-fb.o +imxdrm-objs := imx-drm-core.o obj-$(CONFIG_DRM_IMX) += imxdrm.o diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 5a60886b3a6b..3e3fd281fe6e 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -381,6 +381,10 @@ static void imx_drm_connector_unregister( drm_mode_group_reinit(imxdrm->drm); } +static struct drm_mode_config_funcs imx_drm_mode_config_funcs = { + .fb_create = drm_fb_cma_create, +}; + /* * Main DRM initialisation. This binds, initialises and registers * with DRM the subcomponents of the driver. @@ -406,8 +410,18 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) */ drm->irq_enabled = true; + /* + * set max width and height as default value(4096x4096). + * this value would be used to check framebuffer size limitation + * at drm_mode_addfb(). + */ + drm->mode_config.min_width = 64; + drm->mode_config.min_height = 64; + drm->mode_config.max_width = 4096; + drm->mode_config.max_height = 4096; + drm->mode_config.funcs = &imx_drm_mode_config_funcs; + drm_mode_config_init(drm); - imx_drm_mode_config_init(drm); mutex_lock(&imxdrm->mutex); diff --git a/drivers/staging/imx-drm/imx-fb.c b/drivers/staging/imx-drm/imx-fb.c deleted file mode 100644 index 03a7b4e14f67..000000000000 --- a/drivers/staging/imx-drm/imx-fb.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * i.MX drm driver - * - * Copyright (C) 2012 Sascha Hauer, Pengutronix - * - * Based on Samsung Exynos code - * - * Copyright (c) 2011 Samsung Electronics Co., 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. - * - */ -#include -#include -#include -#include -#include -#include - -#include "imx-drm.h" - -static struct drm_mode_config_funcs imx_drm_mode_config_funcs = { - .fb_create = drm_fb_cma_create, -}; - -void imx_drm_mode_config_init(struct drm_device *dev) -{ - dev->mode_config.min_width = 64; - dev->mode_config.min_height = 64; - - /* - * set max width and height as default value(4096x4096). - * this value would be used to check framebuffer size limitation - * at drm_mode_addfb(). - */ - dev->mode_config.max_width = 4096; - dev->mode_config.max_height = 4096; - - dev->mode_config.funcs = &imx_drm_mode_config_funcs; -} From 32266b4520352f5fbae2f236c50daf4fa49c860d Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 12:26:23 +0000 Subject: [PATCH 0419/1375] imx-drm: use supplied drm_device where possible The component helper provides us the drm_device which is being registered. Rather than having to reference a global in imx-drm-core, use this to get the imxdrm device, and also use it to register the CRTC against. This means we never have CRTCs/encoders/connectors without the drivers private data being accessible. Remove the module owner field as well; this provides no protection against the device being unbound. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 34 ++++---------------------- drivers/staging/imx-drm/imx-drm.h | 4 +-- drivers/staging/imx-drm/ipuv3-crtc.c | 9 ++++--- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 3e3fd281fe6e..3d1c6b6c4388 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -52,7 +52,6 @@ struct imx_drm_crtc { struct imx_drm_device *imxdrm; int pipe; struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; - struct module *owner; struct crtc_cookie cookie; int mux_id; }; @@ -74,7 +73,6 @@ static int legacyfb_depth = 16; module_param(legacyfb_depth, int, 0444); static void imx_drm_device_put(void); -static struct imx_drm_device *__imx_drm_device(void); int imx_drm_crtc_id(struct imx_drm_crtc *crtc) { @@ -114,7 +112,7 @@ static int imx_drm_driver_unload(struct drm_device *drm) struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc) { - struct imx_drm_device *imxdrm = __imx_drm_device(); + struct imx_drm_device *imxdrm = crtc->dev->dev_private; unsigned i; for (i = 0; i < MAX_CRTC; i++) @@ -241,7 +239,6 @@ static struct drm_device *imx_drm_device_get(void) struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_encoder *enc; struct imx_drm_connector *con; - struct imx_drm_crtc *crtc; list_for_each_entry(enc, &imxdrm->encoder_list, list) { if (!try_module_get(enc->owner)) { @@ -259,19 +256,8 @@ static struct drm_device *imx_drm_device_get(void) } } - list_for_each_entry(crtc, &imxdrm->crtc_list, list) { - if (!try_module_get(crtc->owner)) { - dev_err(imxdrm->dev, "could not get module %s\n", - module_name(crtc->owner)); - goto unwind_crtc; - } - } - return imxdrm->drm; -unwind_crtc: - list_for_each_entry_continue_reverse(crtc, &imxdrm->crtc_list, list) - module_put(crtc->owner); unwind_con: list_for_each_entry_continue_reverse(con, &imxdrm->connector_list, list) module_put(con->owner); @@ -290,13 +276,9 @@ static void imx_drm_device_put(void) struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_encoder *enc; struct imx_drm_connector *con; - struct imx_drm_crtc *crtc; mutex_lock(&imxdrm->mutex); - list_for_each_entry(crtc, &imxdrm->crtc_list, list) - module_put(crtc->owner); - list_for_each_entry(con, &imxdrm->connector_list, list) module_put(con->owner); @@ -536,12 +518,12 @@ static void imx_drm_update_possible_crtcs(void) * The return value if !NULL is a cookie for the caller to pass to * imx_drm_remove_crtc later. */ -int imx_drm_add_crtc(struct drm_crtc *crtc, +int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, struct imx_drm_crtc **new_crtc, const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs, - struct module *owner, void *cookie, int id) + void *cookie, int id) { - struct imx_drm_device *imxdrm = __imx_drm_device(); + struct imx_drm_device *imxdrm = drm->dev_private; struct imx_drm_crtc *imx_drm_crtc; int ret; @@ -575,8 +557,6 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, imx_drm_crtc->crtc = crtc; imx_drm_crtc->imxdrm = imxdrm; - imx_drm_crtc->owner = owner; - imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc; *new_crtc = imx_drm_crtc; @@ -588,11 +568,9 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, drm_crtc_helper_add(crtc, imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs); - drm_crtc_init(imxdrm->drm, crtc, + drm_crtc_init(drm, crtc, imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); - drm_mode_group_reinit(imxdrm->drm); - imx_drm_update_possible_crtcs(); mutex_unlock(&imxdrm->mutex); @@ -622,8 +600,6 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) imxdrm->crtc[imx_drm_crtc->pipe] = NULL; - drm_mode_group_reinit(imxdrm->drm); - mutex_unlock(&imxdrm->mutex); kfree(imx_drm_crtc); diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index d1fb1146240e..78465239ed4c 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -25,10 +25,10 @@ struct imx_drm_crtc_helper_funcs { const struct drm_crtc_funcs *crtc_funcs; }; -int imx_drm_add_crtc(struct drm_crtc *crtc, +int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, struct imx_drm_crtc **new_crtc, const struct imx_drm_crtc_helper_funcs *imx_helper_funcs, - struct module *owner, void *cookie, int id); + void *cookie, int id); int imx_drm_remove_crtc(struct imx_drm_crtc *); int imx_drm_init_drm(struct platform_device *pdev, int preferred_bpp); diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index d779ad2d1f4e..e646017c32ac 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -336,7 +336,7 @@ err_out: } static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, - struct ipu_client_platformdata *pdata) + struct ipu_client_platformdata *pdata, struct drm_device *drm) { struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); int dp = -EINVAL; @@ -350,9 +350,9 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, return ret; } - ret = imx_drm_add_crtc(&ipu_crtc->base, + ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc, - &ipu_crtc_helper_funcs, THIS_MODULE, + &ipu_crtc_helper_funcs, ipu_crtc->dev->parent->of_node, pdata->di); if (ret) { dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret); @@ -404,6 +404,7 @@ err_put_resources: static int ipu_drm_bind(struct device *dev, struct device *master, void *data) { struct ipu_client_platformdata *pdata = dev->platform_data; + struct drm_device *drm = data; struct ipu_crtc *ipu_crtc; int ret; @@ -413,7 +414,7 @@ static int ipu_drm_bind(struct device *dev, struct device *master, void *data) ipu_crtc->dev = dev; - ret = ipu_crtc_init(ipu_crtc, pdata); + ret = ipu_crtc_init(ipu_crtc, pdata, drm); if (ret) return ret; From 9e2d410d18bf93c620877a4ea0cab213362a2dda Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 14:04:47 +0000 Subject: [PATCH 0420/1375] imx-drm: imx-drm-core: provide helper function to parse possible crtcs Provide a helper function to parse possible crtcs before the encoder is registered. The crtc mask is derived from the position of the CRTCs registered in the drm_device. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 66 ++++++++++++++++++++++++++ drivers/staging/imx-drm/imx-drm.h | 2 + 2 files changed, 68 insertions(+) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 3d1c6b6c4388..5cac6ee24472 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -658,6 +658,72 @@ err_busy: } EXPORT_SYMBOL_GPL(imx_drm_add_encoder); +/* + * Find the DRM CRTC possible mask for the device node cookie/id. + * + * The encoder possible masks are defined by their position in the + * mode_config crtc_list. This means that CRTCs must not be added + * or removed once the DRM device has been fully initialised. + */ +static uint32_t imx_drm_find_crtc_mask(struct imx_drm_device *imxdrm, + void *cookie, int id) +{ + unsigned i; + + for (i = 0; i < MAX_CRTC; i++) { + struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[i]; + if (imx_drm_crtc && imx_drm_crtc->cookie.id == id && + imx_drm_crtc->cookie.cookie == cookie) + return drm_crtc_mask(imx_drm_crtc->crtc); + } + + return 0; +} + +int imx_drm_encoder_parse_of(struct drm_device *drm, + struct drm_encoder *encoder, struct device_node *np) +{ + struct imx_drm_device *imxdrm = drm->dev_private; + uint32_t crtc_mask = 0; + int i, ret = 0; + + for (i = 0; !ret; i++) { + struct of_phandle_args args; + uint32_t mask; + int id; + + ret = of_parse_phandle_with_args(np, "crtcs", "#crtc-cells", i, + &args); + if (ret == -ENOENT) + break; + if (ret < 0) + return ret; + + id = args.args_count > 0 ? args.args[0] : 0; + mask = imx_drm_find_crtc_mask(imxdrm, args.np, id); + of_node_put(args.np); + + /* + * If we failed to find the CRTC(s) which this encoder is + * supposed to be connected to, it's because the CRTC has + * not been registered yet. Defer probing, and hope that + * the required CRTC is added later. + */ + if (mask == 0) + return -EPROBE_DEFER; + + crtc_mask |= mask; + } + + encoder->possible_crtcs = crtc_mask; + + /* FIXME: this is the mask of outputs which can clone this output. */ + encoder->possible_clones = ~0; + + return 0; +} +EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of); + int imx_drm_encoder_add_possible_crtcs( struct imx_drm_encoder *imx_drm_encoder, struct device_node *np) diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index 78465239ed4c..49d4aaf33f97 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -64,6 +64,8 @@ struct device_node; int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder); int imx_drm_encoder_add_possible_crtcs(struct imx_drm_encoder *imx_drm_encoder, struct device_node *np); +int imx_drm_encoder_parse_of(struct drm_device *drm, + struct drm_encoder *encoder, struct device_node *np); int imx_drm_connector_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode); From 8a51a33b3562de301d522eea1d167c243a16b6df Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 13:28:24 +0000 Subject: [PATCH 0421/1375] imx-drm: imx-drm-core: provide common connector and encoder cleanup functions Provide two helper functions to assist with cleaning up imx-drm connectors and encoders. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 13 +++++++++++++ drivers/staging/imx-drm/imx-drm.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 5cac6ee24472..1f50acd5a982 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -363,6 +363,19 @@ static void imx_drm_connector_unregister( drm_mode_group_reinit(imxdrm->drm); } +void imx_drm_connector_destroy(struct drm_connector *connector) +{ + drm_sysfs_connector_remove(connector); + drm_connector_cleanup(connector); +} +EXPORT_SYMBOL_GPL(imx_drm_connector_destroy); + +void imx_drm_encoder_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} +EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); + static struct drm_mode_config_funcs imx_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, }; diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index 49d4aaf33f97..0543606c587a 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -8,6 +8,7 @@ struct drm_crtc; struct drm_connector; struct drm_device; +struct drm_display_mode; struct drm_encoder; struct imx_drm_crtc; struct drm_fbdev_cma; @@ -69,5 +70,7 @@ int imx_drm_encoder_parse_of(struct drm_device *drm, int imx_drm_connector_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode); +void imx_drm_connector_destroy(struct drm_connector *connector); +void imx_drm_encoder_destroy(struct drm_encoder *encoder); #endif /* _IMX_DRM_H_ */ From 1b3f7675663384be878c9a32b76daa482e2bbe18 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 13:30:48 +0000 Subject: [PATCH 0422/1375] imx-drm: initialise drm components directly Now that our bind function is only ever called during the main DRM driver ->load callback, we don't need to have the imx_drm_connector or imx_drm_encoder abstractions anymore. So let's get rid of it, and move the DRM connector and encoder setup into the connector support files. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 56 +++++------------- drivers/staging/imx-drm/imx-ldb.c | 68 +++++++--------------- drivers/staging/imx-drm/imx-tve.c | 58 +++++------------- drivers/staging/imx-drm/parallel-display.c | 61 ++++++------------- 4 files changed, 69 insertions(+), 174 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 14b4a4b976b9..8c586453df11 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -113,9 +113,7 @@ struct hdmi_data_info { struct imx_hdmi { struct drm_connector connector; - struct imx_drm_connector *imx_drm_connector; struct drm_encoder encoder; - struct imx_drm_encoder *imx_drm_encoder; enum imx_hdmi_devtype dev_type; struct device *dev; @@ -1378,10 +1376,6 @@ static enum drm_connector_status imx_hdmi_connector_detect(struct drm_connector return connector_status_connected; } -static void imx_hdmi_connector_destroy(struct drm_connector *connector) -{ -} - static int imx_hdmi_connector_get_modes(struct drm_connector *connector) { struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi, @@ -1467,13 +1461,8 @@ static void imx_hdmi_encoder_commit(struct drm_encoder *encoder) imx_hdmi_poweron(hdmi); } -static void imx_hdmi_encoder_destroy(struct drm_encoder *encoder) -{ - return; -} - static struct drm_encoder_funcs imx_hdmi_encoder_funcs = { - .destroy = imx_hdmi_encoder_destroy, + .destroy = imx_drm_encoder_destroy, }; static struct drm_encoder_helper_funcs imx_hdmi_encoder_helper_funcs = { @@ -1489,7 +1478,7 @@ static struct drm_connector_funcs imx_hdmi_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_hdmi_connector_detect, - .destroy = imx_hdmi_connector_destroy, + .destroy = imx_drm_connector_destroy, }; static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = { @@ -1529,34 +1518,23 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) return IRQ_HANDLED; } -static int imx_hdmi_register(struct imx_hdmi *hdmi) +static int imx_hdmi_register(struct drm_device *drm, struct imx_hdmi *hdmi) { int ret; - hdmi->connector.funcs = &imx_hdmi_connector_funcs; - hdmi->encoder.funcs = &imx_hdmi_encoder_funcs; - - hdmi->encoder.encoder_type = DRM_MODE_ENCODER_TMDS; - hdmi->connector.connector_type = DRM_MODE_CONNECTOR_HDMIA; + ret = imx_drm_encoder_parse_of(drm, &hdmi->encoder, + hdmi->dev->of_node); + if (ret) + return ret; drm_encoder_helper_add(&hdmi->encoder, &imx_hdmi_encoder_helper_funcs); - ret = imx_drm_add_encoder(&hdmi->encoder, &hdmi->imx_drm_encoder, - THIS_MODULE); - if (ret) { - dev_err(hdmi->dev, "adding encoder failed: %d\n", ret); - return ret; - } + drm_encoder_init(drm, &hdmi->encoder, &imx_hdmi_encoder_funcs, + DRM_MODE_ENCODER_TMDS); drm_connector_helper_add(&hdmi->connector, &imx_hdmi_connector_helper_funcs); - - ret = imx_drm_add_connector(&hdmi->connector, - &hdmi->imx_drm_connector, THIS_MODULE); - if (ret) { - imx_drm_remove_encoder(hdmi->imx_drm_encoder); - dev_err(hdmi->dev, "adding connector failed: %d\n", ret); - return ret; - } + drm_connector_init(drm, &hdmi->connector, &imx_hdmi_connector_funcs, + DRM_MODE_CONNECTOR_HDMIA); hdmi->connector.encoder = &hdmi->encoder; @@ -1588,6 +1566,7 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) struct platform_device *pdev = to_platform_device(dev); const struct of_device_id *of_id = of_match_device(imx_hdmi_dt_ids, dev); + struct drm_device *drm = data; struct device_node *np = dev->of_node; struct device_node *ddc_node; struct imx_hdmi *hdmi; @@ -1695,12 +1674,10 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) if (ret) goto err_iahb; - ret = imx_hdmi_register(hdmi); + ret = imx_hdmi_register(drm, hdmi); if (ret) goto err_iahb; - imx_drm_encoder_add_possible_crtcs(hdmi->imx_drm_encoder, np); - dev_set_drvdata(dev, hdmi); return 0; @@ -1717,12 +1694,9 @@ static void imx_hdmi_unbind(struct device *dev, struct device *master, void *data) { struct imx_hdmi *hdmi = dev_get_drvdata(dev); - struct drm_connector *connector = &hdmi->connector; - struct drm_encoder *encoder = &hdmi->encoder; - drm_mode_connector_detach_encoder(connector, encoder); - imx_drm_remove_connector(hdmi->imx_drm_connector); - imx_drm_remove_encoder(hdmi->imx_drm_encoder); + hdmi->connector.funcs->destroy(&hdmi->connector); + hdmi->encoder.funcs->destroy(&hdmi->encoder); clk_disable_unprepare(hdmi->iahb_clk); clk_disable_unprepare(hdmi->isfr_clk); diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index d00f93f3440d..5168c76cff53 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -59,9 +59,8 @@ struct imx_ldb; struct imx_ldb_channel { struct imx_ldb *ldb; struct drm_connector connector; - struct imx_drm_connector *imx_drm_connector; struct drm_encoder encoder; - struct imx_drm_encoder *imx_drm_encoder; + struct device_node *child; int chno; void *edid; int edid_len; @@ -92,11 +91,6 @@ static enum drm_connector_status imx_ldb_connector_detect( return connector_status_connected; } -static void imx_ldb_connector_destroy(struct drm_connector *connector) -{ - /* do not free here */ -} - static int imx_ldb_connector_get_modes(struct drm_connector *connector) { struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector); @@ -308,16 +302,11 @@ static void imx_ldb_encoder_disable(struct drm_encoder *encoder) } } -static void imx_ldb_encoder_destroy(struct drm_encoder *encoder) -{ - /* do not free here */ -} - static struct drm_connector_funcs imx_ldb_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_ldb_connector_detect, - .destroy = imx_ldb_connector_destroy, + .destroy = imx_drm_connector_destroy, }; static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = { @@ -327,7 +316,7 @@ static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = { }; static struct drm_encoder_funcs imx_ldb_encoder_funcs = { - .destroy = imx_ldb_encoder_destroy, + .destroy = imx_drm_encoder_destroy, }; static struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = { @@ -354,45 +343,36 @@ static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno) return PTR_ERR_OR_ZERO(ldb->clk_pll[chno]); } -static int imx_ldb_register(struct imx_ldb_channel *imx_ldb_ch) +static int imx_ldb_register(struct drm_device *drm, + struct imx_ldb_channel *imx_ldb_ch) { - int ret; struct imx_ldb *ldb = imx_ldb_ch->ldb; + int ret; + + ret = imx_drm_encoder_parse_of(drm, &imx_ldb_ch->encoder, + imx_ldb_ch->child); + if (ret) + return ret; ret = imx_ldb_get_clk(ldb, imx_ldb_ch->chno); if (ret) return ret; + if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) { - ret |= imx_ldb_get_clk(ldb, 1); + ret = imx_ldb_get_clk(ldb, 1); if (ret) return ret; } - imx_ldb_ch->connector.funcs = &imx_ldb_connector_funcs; - imx_ldb_ch->encoder.funcs = &imx_ldb_encoder_funcs; - - imx_ldb_ch->encoder.encoder_type = DRM_MODE_ENCODER_LVDS; - imx_ldb_ch->connector.connector_type = DRM_MODE_CONNECTOR_LVDS; - drm_encoder_helper_add(&imx_ldb_ch->encoder, &imx_ldb_encoder_helper_funcs); - ret = imx_drm_add_encoder(&imx_ldb_ch->encoder, - &imx_ldb_ch->imx_drm_encoder, THIS_MODULE); - if (ret) { - dev_err(ldb->dev, "adding encoder failed with %d\n", ret); - return ret; - } + drm_encoder_init(drm, &imx_ldb_ch->encoder, &imx_ldb_encoder_funcs, + DRM_MODE_ENCODER_LVDS); drm_connector_helper_add(&imx_ldb_ch->connector, &imx_ldb_connector_helper_funcs); - - ret = imx_drm_add_connector(&imx_ldb_ch->connector, - &imx_ldb_ch->imx_drm_connector, THIS_MODULE); - if (ret) { - imx_drm_remove_encoder(imx_ldb_ch->imx_drm_encoder); - dev_err(ldb->dev, "adding connector failed with %d\n", ret); - return ret; - } + drm_connector_init(drm, &imx_ldb_ch->connector, + &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS); drm_mode_connector_attach_encoder(&imx_ldb_ch->connector, &imx_ldb_ch->encoder); @@ -453,6 +433,7 @@ MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids); static int imx_ldb_bind(struct device *dev, struct device *master, void *data) { + struct drm_device *drm = data; struct device_node *np = dev->of_node; const struct of_device_id *of_id = of_match_device(imx_ldb_dt_ids, dev); @@ -523,6 +504,7 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) channel = &imx_ldb->channel[i]; channel->ldb = imx_ldb; channel->chno = i; + channel->child = child; edidp = of_get_property(child, "edid", &channel->edid_len); if (edidp) { @@ -565,11 +547,9 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) return -EINVAL; } - ret = imx_ldb_register(channel); + ret = imx_ldb_register(drm, channel); if (ret) return ret; - - imx_drm_encoder_add_possible_crtcs(channel->imx_drm_encoder, child); } dev_set_drvdata(dev, imx_ldb); @@ -585,13 +565,9 @@ static void imx_ldb_unbind(struct device *dev, struct device *master, for (i = 0; i < 2; i++) { struct imx_ldb_channel *channel = &imx_ldb->channel[i]; - struct drm_connector *connector = &channel->connector; - struct drm_encoder *encoder = &channel->encoder; - drm_mode_connector_detach_encoder(connector, encoder); - - imx_drm_remove_connector(channel->imx_drm_connector); - imx_drm_remove_encoder(channel->imx_drm_encoder); + channel->connector.funcs->destroy(&channel->connector); + channel->encoder.funcs->destroy(&channel->encoder); } } diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index ad840d78a09a..702c0c3204ed 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -111,9 +111,7 @@ enum { struct imx_tve { struct drm_connector connector; - struct imx_drm_connector *imx_drm_connector; struct drm_encoder encoder; - struct imx_drm_encoder *imx_drm_encoder; struct device *dev; spinlock_t lock; /* register lock */ bool enabled; @@ -226,11 +224,6 @@ static enum drm_connector_status imx_tve_connector_detect( return connector_status_connected; } -static void imx_tve_connector_destroy(struct drm_connector *connector) -{ - /* do not free here */ -} - static int imx_tve_connector_get_modes(struct drm_connector *connector) { struct imx_tve *tve = con_to_tve(connector); @@ -368,16 +361,11 @@ static void imx_tve_encoder_disable(struct drm_encoder *encoder) tve_disable(tve); } -static void imx_tve_encoder_destroy(struct drm_encoder *encoder) -{ - /* do not free here */ -} - static struct drm_connector_funcs imx_tve_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_tve_connector_detect, - .destroy = imx_tve_connector_destroy, + .destroy = imx_drm_connector_destroy, }; static struct drm_connector_helper_funcs imx_tve_connector_helper_funcs = { @@ -387,7 +375,7 @@ static struct drm_connector_helper_funcs imx_tve_connector_helper_funcs = { }; static struct drm_encoder_funcs imx_tve_encoder_funcs = { - .destroy = imx_tve_encoder_destroy, + .destroy = imx_drm_encoder_destroy, }; static struct drm_encoder_helper_funcs imx_tve_encoder_helper_funcs = { @@ -507,7 +495,7 @@ static int tve_clk_init(struct imx_tve *tve, void __iomem *base) return 0; } -static int imx_tve_register(struct imx_tve *tve) +static int imx_tve_register(struct drm_device *drm, struct imx_tve *tve) { int encoder_type; int ret; @@ -515,30 +503,19 @@ static int imx_tve_register(struct imx_tve *tve) encoder_type = tve->mode == TVE_MODE_VGA ? DRM_MODE_ENCODER_DAC : DRM_MODE_ENCODER_TVDAC; - tve->connector.funcs = &imx_tve_connector_funcs; - tve->encoder.funcs = &imx_tve_encoder_funcs; - - tve->encoder.encoder_type = encoder_type; - tve->connector.connector_type = DRM_MODE_CONNECTOR_VGA; + ret = imx_drm_encoder_parse_of(drm, &tve->encoder, + tve->dev->of_node); + if (ret) + return ret; drm_encoder_helper_add(&tve->encoder, &imx_tve_encoder_helper_funcs); - ret = imx_drm_add_encoder(&tve->encoder, &tve->imx_drm_encoder, - THIS_MODULE); - if (ret) { - dev_err(tve->dev, "adding encoder failed with %d\n", ret); - return ret; - } + drm_encoder_init(drm, &tve->encoder, &imx_tve_encoder_funcs, + encoder_type); drm_connector_helper_add(&tve->connector, &imx_tve_connector_helper_funcs); - - ret = imx_drm_add_connector(&tve->connector, - &tve->imx_drm_connector, THIS_MODULE); - if (ret) { - imx_drm_remove_encoder(tve->imx_drm_encoder); - dev_err(tve->dev, "adding connector failed with %d\n", ret); - return ret; - } + drm_connector_init(drm, &tve->connector, &imx_tve_connector_funcs, + DRM_MODE_CONNECTOR_VGA); drm_mode_connector_attach_encoder(&tve->connector, &tve->encoder); @@ -587,6 +564,7 @@ static const int of_get_tve_mode(struct device_node *np) static int imx_tve_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); + struct drm_device *drm = data; struct device_node *np = dev->of_node; struct device_node *ddc_node; struct imx_tve *tve; @@ -701,12 +679,10 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data) /* disable cable detection for VGA mode */ ret = regmap_write(tve->regmap, TVE_CD_CONT_REG, 0); - ret = imx_tve_register(tve); + ret = imx_tve_register(drm, tve); if (ret) return ret; - ret = imx_drm_encoder_add_possible_crtcs(tve->imx_drm_encoder, np); - dev_set_drvdata(dev, tve); return 0; @@ -716,13 +692,9 @@ static void imx_tve_unbind(struct device *dev, struct device *master, void *data) { struct imx_tve *tve = dev_get_drvdata(dev); - struct drm_connector *connector = &tve->connector; - struct drm_encoder *encoder = &tve->encoder; - drm_mode_connector_detach_encoder(connector, encoder); - - imx_drm_remove_connector(tve->imx_drm_connector); - imx_drm_remove_encoder(tve->imx_drm_encoder); + tve->connector.funcs->destroy(&tve->connector); + tve->encoder.funcs->destroy(&tve->encoder); if (!IS_ERR(tve->dac_reg)) regulator_disable(tve->dac_reg); diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 4019cae35ff9..d610f0726bb2 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -33,9 +33,7 @@ struct imx_parallel_display { struct drm_connector connector; - struct imx_drm_connector *imx_drm_connector; struct drm_encoder encoder; - struct imx_drm_encoder *imx_drm_encoder; struct device *dev; void *edid; int edid_len; @@ -50,11 +48,6 @@ static enum drm_connector_status imx_pd_connector_detect( return connector_status_connected; } -static void imx_pd_connector_destroy(struct drm_connector *connector) -{ - /* do not free here */ -} - static int imx_pd_connector_get_modes(struct drm_connector *connector) { struct imx_parallel_display *imxpd = con_to_imxpd(connector); @@ -126,16 +119,11 @@ static void imx_pd_encoder_disable(struct drm_encoder *encoder) { } -static void imx_pd_encoder_destroy(struct drm_encoder *encoder) -{ - /* do not free here */ -} - static struct drm_connector_funcs imx_pd_connector_funcs = { .dpms = drm_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_pd_connector_detect, - .destroy = imx_pd_connector_destroy, + .destroy = imx_drm_connector_destroy, }; static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = { @@ -145,7 +133,7 @@ static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = { }; static struct drm_encoder_funcs imx_pd_encoder_funcs = { - .destroy = imx_pd_encoder_destroy, + .destroy = imx_drm_encoder_destroy, }; static struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = { @@ -157,36 +145,26 @@ static struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = { .disable = imx_pd_encoder_disable, }; -static int imx_pd_register(struct imx_parallel_display *imxpd) +static int imx_pd_register(struct drm_device *drm, + struct imx_parallel_display *imxpd) { int ret; - drm_mode_connector_attach_encoder(&imxpd->connector, &imxpd->encoder); - - imxpd->connector.funcs = &imx_pd_connector_funcs; - imxpd->encoder.funcs = &imx_pd_encoder_funcs; - - imxpd->encoder.encoder_type = DRM_MODE_ENCODER_NONE; - imxpd->connector.connector_type = DRM_MODE_CONNECTOR_VGA; + ret = imx_drm_encoder_parse_of(drm, &imxpd->encoder, + imxpd->dev->of_node); + if (ret) + return ret; drm_encoder_helper_add(&imxpd->encoder, &imx_pd_encoder_helper_funcs); - ret = imx_drm_add_encoder(&imxpd->encoder, &imxpd->imx_drm_encoder, - THIS_MODULE); - if (ret) { - dev_err(imxpd->dev, "adding encoder failed with %d\n", ret); - return ret; - } + drm_encoder_init(drm, &imxpd->encoder, &imx_pd_encoder_funcs, + DRM_MODE_ENCODER_NONE); drm_connector_helper_add(&imxpd->connector, &imx_pd_connector_helper_funcs); + drm_connector_init(drm, &imxpd->connector, &imx_pd_connector_funcs, + DRM_MODE_CONNECTOR_VGA); - ret = imx_drm_add_connector(&imxpd->connector, - &imxpd->imx_drm_connector, THIS_MODULE); - if (ret) { - imx_drm_remove_encoder(imxpd->imx_drm_encoder); - dev_err(imxpd->dev, "adding connector failed with %d\n", ret); - return ret; - } + drm_mode_connector_attach_encoder(&imxpd->connector, &imxpd->encoder); imxpd->connector.encoder = &imxpd->encoder; @@ -195,6 +173,7 @@ static int imx_pd_register(struct imx_parallel_display *imxpd) static int imx_pd_bind(struct device *dev, struct device *master, void *data) { + struct drm_device *drm = data; struct device_node *np = dev->of_node; const u8 *edidp; struct imx_parallel_display *imxpd; @@ -221,12 +200,10 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) imxpd->dev = dev; - ret = imx_pd_register(imxpd); + ret = imx_pd_register(drm, imxpd); if (ret) return ret; - ret = imx_drm_encoder_add_possible_crtcs(imxpd->imx_drm_encoder, np); - dev_set_drvdata(dev, imxpd); return 0; @@ -236,13 +213,9 @@ static void imx_pd_unbind(struct device *dev, struct device *master, void *data) { struct imx_parallel_display *imxpd = dev_get_drvdata(dev); - struct drm_connector *connector = &imxpd->connector; - struct drm_encoder *encoder = &imxpd->encoder; - drm_mode_connector_detach_encoder(connector, encoder); - - imx_drm_remove_connector(imxpd->imx_drm_connector); - imx_drm_remove_encoder(imxpd->imx_drm_encoder); + imxpd->encoder.funcs->destroy(&imxpd->encoder); + imxpd->connector.funcs->destroy(&imxpd->connector); } static const struct component_ops imx_pd_ops = { From 8d71de61526924f516548707a5f16ac9e564aeee Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 13:55:34 +0000 Subject: [PATCH 0423/1375] imx-drm: imx-drm-core: remove imx_drm_connector and imx_drm_encoder code The core imx_drm_connector and imx_drm_encoder code is no longer required - the connectors and encoders are all using the component support, so we can remove this. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 371 +------------------------ drivers/staging/imx-drm/imx-drm.h | 14 - 2 files changed, 1 insertion(+), 384 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 1f50acd5a982..b27c42539e49 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -40,8 +40,6 @@ struct imx_drm_device { struct drm_device *drm; struct device *dev; struct imx_drm_crtc *crtc[MAX_CRTC]; - struct list_head encoder_list; - struct list_head connector_list; struct mutex mutex; int pipes; struct drm_fbdev_cma *fbhelper; @@ -56,24 +54,9 @@ struct imx_drm_crtc { int mux_id; }; -struct imx_drm_encoder { - struct drm_encoder *encoder; - struct list_head list; - struct module *owner; - struct list_head possible_crtcs; -}; - -struct imx_drm_connector { - struct drm_connector *connector; - struct list_head list; - struct module *owner; -}; - static int legacyfb_depth = 16; module_param(legacyfb_depth, int, 0444); -static void imx_drm_device_put(void); - int imx_drm_crtc_id(struct imx_drm_crtc *crtc) { return crtc->pipe; @@ -101,8 +84,6 @@ static int imx_drm_driver_unload(struct drm_device *drm) component_unbind_all(drm->dev, drm); - imx_drm_device_put(); - drm_vblank_cleanup(drm); drm_kms_helper_poll_fini(drm); drm_mode_config_cleanup(drm); @@ -234,135 +215,6 @@ static struct imx_drm_device *__imx_drm_device(void) return imx_drm_device; } -static struct drm_device *imx_drm_device_get(void) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct imx_drm_encoder *enc; - struct imx_drm_connector *con; - - list_for_each_entry(enc, &imxdrm->encoder_list, list) { - if (!try_module_get(enc->owner)) { - dev_err(imxdrm->dev, "could not get module %s\n", - module_name(enc->owner)); - goto unwind_enc; - } - } - - list_for_each_entry(con, &imxdrm->connector_list, list) { - if (!try_module_get(con->owner)) { - dev_err(imxdrm->dev, "could not get module %s\n", - module_name(con->owner)); - goto unwind_con; - } - } - - return imxdrm->drm; - -unwind_con: - list_for_each_entry_continue_reverse(con, &imxdrm->connector_list, list) - module_put(con->owner); -unwind_enc: - list_for_each_entry_continue_reverse(enc, &imxdrm->encoder_list, list) - module_put(enc->owner); - - mutex_unlock(&imxdrm->mutex); - - return NULL; - -} - -static void imx_drm_device_put(void) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct imx_drm_encoder *enc; - struct imx_drm_connector *con; - - mutex_lock(&imxdrm->mutex); - - list_for_each_entry(con, &imxdrm->connector_list, list) - module_put(con->owner); - - list_for_each_entry(enc, &imxdrm->encoder_list, list) - module_put(enc->owner); - - mutex_unlock(&imxdrm->mutex); -} - -static int drm_mode_group_reinit(struct drm_device *dev) -{ - struct drm_mode_group *group = &dev->primary->mode_group; - uint32_t *id_list = group->id_list; - int ret; - - ret = drm_mode_group_init_legacy_group(dev, group); - if (ret < 0) - return ret; - - kfree(id_list); - return 0; -} - -/* - * register an encoder to the drm core - */ -static int imx_drm_encoder_register(struct imx_drm_encoder *imx_drm_encoder) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - INIT_LIST_HEAD(&imx_drm_encoder->possible_crtcs); - - drm_encoder_init(imxdrm->drm, imx_drm_encoder->encoder, - imx_drm_encoder->encoder->funcs, - imx_drm_encoder->encoder->encoder_type); - - drm_mode_group_reinit(imxdrm->drm); - - return 0; -} - -/* - * unregister an encoder from the drm core - */ -static void imx_drm_encoder_unregister(struct imx_drm_encoder - *imx_drm_encoder) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - drm_encoder_cleanup(imx_drm_encoder->encoder); - - drm_mode_group_reinit(imxdrm->drm); -} - -/* - * register a connector to the drm core - */ -static int imx_drm_connector_register( - struct imx_drm_connector *imx_drm_connector) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - drm_connector_init(imxdrm->drm, imx_drm_connector->connector, - imx_drm_connector->connector->funcs, - imx_drm_connector->connector->connector_type); - drm_mode_group_reinit(imxdrm->drm); - - return 0; -} - -/* - * unregister a connector from the drm core - */ -static void imx_drm_connector_unregister( - struct imx_drm_connector *imx_drm_connector) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - drm_sysfs_connector_remove(imx_drm_connector->connector); - drm_connector_cleanup(imx_drm_connector->connector); - - drm_mode_group_reinit(imxdrm->drm); -} - void imx_drm_connector_destroy(struct drm_connector *connector) { drm_sysfs_connector_remove(connector); @@ -439,12 +291,8 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) */ drm->vblank_disable_allowed = true; - if (!imx_drm_device_get()) { - ret = -EINVAL; - goto err_vblank; - } - platform_set_drvdata(drm->platformdev, drm); + mutex_unlock(&imxdrm->mutex); /* Now try and bind all our sub-components */ @@ -492,7 +340,6 @@ err_unbind: component_unbind_all(drm->dev, drm); err_relock: mutex_lock(&imxdrm->mutex); -err_vblank: drm_vblank_cleanup(drm); err_kms: drm_kms_helper_poll_fini(drm); @@ -502,29 +349,6 @@ err_kms: return ret; } -static void imx_drm_update_possible_crtcs(void) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct imx_drm_crtc *imx_drm_crtc; - struct imx_drm_encoder *enc; - struct crtc_cookie *cookie; - - list_for_each_entry(enc, &imxdrm->encoder_list, list) { - u32 possible_crtcs = 0; - - list_for_each_entry(cookie, &enc->possible_crtcs, list) { - list_for_each_entry(imx_drm_crtc, &imxdrm->crtc_list, list) { - if (imx_drm_crtc->cookie.cookie == cookie->cookie && - imx_drm_crtc->cookie.id == cookie->id) { - possible_crtcs |= 1 << imx_drm_crtc->pipe; - } - } - } - enc->encoder->possible_crtcs = possible_crtcs; - enc->encoder->possible_clones = possible_crtcs; - } -} - /* * imx_drm_add_crtc - add a new crtc * @@ -584,8 +408,6 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, drm_crtc_init(drm, crtc, imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); - imx_drm_update_possible_crtcs(); - mutex_unlock(&imxdrm->mutex); return 0; @@ -621,56 +443,6 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) } EXPORT_SYMBOL_GPL(imx_drm_remove_crtc); -/* - * imx_drm_add_encoder - add a new encoder - */ -int imx_drm_add_encoder(struct drm_encoder *encoder, - struct imx_drm_encoder **newenc, struct module *owner) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct imx_drm_encoder *imx_drm_encoder; - int ret; - - mutex_lock(&imxdrm->mutex); - - if (imxdrm->drm->open_count) { - ret = -EBUSY; - goto err_busy; - } - - imx_drm_encoder = kzalloc(sizeof(*imx_drm_encoder), GFP_KERNEL); - if (!imx_drm_encoder) { - ret = -ENOMEM; - goto err_alloc; - } - - imx_drm_encoder->encoder = encoder; - imx_drm_encoder->owner = owner; - - ret = imx_drm_encoder_register(imx_drm_encoder); - if (ret) { - ret = -ENOMEM; - goto err_register; - } - - list_add_tail(&imx_drm_encoder->list, &imxdrm->encoder_list); - - *newenc = imx_drm_encoder; - - mutex_unlock(&imxdrm->mutex); - - return 0; - -err_register: - kfree(imx_drm_encoder); -err_alloc: -err_busy: - mutex_unlock(&imxdrm->mutex); - - return ret; -} -EXPORT_SYMBOL_GPL(imx_drm_add_encoder); - /* * Find the DRM CRTC possible mask for the device node cookie/id. * @@ -737,49 +509,6 @@ int imx_drm_encoder_parse_of(struct drm_device *drm, } EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of); -int imx_drm_encoder_add_possible_crtcs( - struct imx_drm_encoder *imx_drm_encoder, - struct device_node *np) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct of_phandle_args args; - struct crtc_cookie *c; - int ret = 0; - int i; - - if (!list_empty(&imx_drm_encoder->possible_crtcs)) - return -EBUSY; - - for (i = 0; !ret; i++) { - ret = of_parse_phandle_with_args(np, "crtcs", - "#crtc-cells", i, &args); - if (ret < 0) - break; - - c = kzalloc(sizeof(*c), GFP_KERNEL); - if (!c) { - of_node_put(args.np); - return -ENOMEM; - } - - c->cookie = args.np; - c->id = args.args_count > 0 ? args.args[0] : 0; - - of_node_put(args.np); - - mutex_lock(&imxdrm->mutex); - - list_add_tail(&c->list, &imx_drm_encoder->possible_crtcs); - - mutex_unlock(&imxdrm->mutex); - } - - imx_drm_update_possible_crtcs(); - - return 0; -} -EXPORT_SYMBOL_GPL(imx_drm_encoder_add_possible_crtcs); - int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder) { struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc); @@ -788,102 +517,6 @@ int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder) } EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id); -/* - * imx_drm_remove_encoder - remove an encoder - */ -int imx_drm_remove_encoder(struct imx_drm_encoder *imx_drm_encoder) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct crtc_cookie *c, *tmp; - - mutex_lock(&imxdrm->mutex); - - imx_drm_encoder_unregister(imx_drm_encoder); - - list_del(&imx_drm_encoder->list); - - list_for_each_entry_safe(c, tmp, &imx_drm_encoder->possible_crtcs, - list) - kfree(c); - - mutex_unlock(&imxdrm->mutex); - - kfree(imx_drm_encoder); - - return 0; -} -EXPORT_SYMBOL_GPL(imx_drm_remove_encoder); - -/* - * imx_drm_add_connector - add a connector - */ -int imx_drm_add_connector(struct drm_connector *connector, - struct imx_drm_connector **new_con, - struct module *owner) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - struct imx_drm_connector *imx_drm_connector; - int ret; - - mutex_lock(&imxdrm->mutex); - - if (imxdrm->drm->open_count) { - ret = -EBUSY; - goto err_busy; - } - - imx_drm_connector = kzalloc(sizeof(*imx_drm_connector), GFP_KERNEL); - if (!imx_drm_connector) { - ret = -ENOMEM; - goto err_alloc; - } - - imx_drm_connector->connector = connector; - imx_drm_connector->owner = owner; - - ret = imx_drm_connector_register(imx_drm_connector); - if (ret) - goto err_register; - - list_add_tail(&imx_drm_connector->list, &imxdrm->connector_list); - - *new_con = imx_drm_connector; - - mutex_unlock(&imxdrm->mutex); - - return 0; - -err_register: - kfree(imx_drm_connector); -err_alloc: -err_busy: - mutex_unlock(&imxdrm->mutex); - - return ret; -} -EXPORT_SYMBOL_GPL(imx_drm_add_connector); - -/* - * imx_drm_remove_connector - remove a connector - */ -int imx_drm_remove_connector(struct imx_drm_connector *imx_drm_connector) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - mutex_lock(&imxdrm->mutex); - - imx_drm_connector_unregister(imx_drm_connector); - - list_del(&imx_drm_connector->list); - - mutex_unlock(&imxdrm->mutex); - - kfree(imx_drm_connector); - - return 0; -} -EXPORT_SYMBOL_GPL(imx_drm_remove_connector); - static const struct drm_ioctl_desc imx_drm_ioctls[] = { /* none so far */ }; @@ -1031,8 +664,6 @@ static int __init imx_drm_init(void) return -ENOMEM; mutex_init(&imx_drm_device->mutex); - INIT_LIST_HEAD(&imx_drm_device->connector_list); - INIT_LIST_HEAD(&imx_drm_device->encoder_list); ret = platform_driver_register(&imx_drm_pdrv); if (ret) diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index 0543606c587a..ae9c96d181fa 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -39,18 +39,6 @@ int imx_drm_crtc_vblank_get(struct imx_drm_crtc *imx_drm_crtc); void imx_drm_crtc_vblank_put(struct imx_drm_crtc *imx_drm_crtc); void imx_drm_handle_vblank(struct imx_drm_crtc *imx_drm_crtc); -struct imx_drm_encoder; -int imx_drm_add_encoder(struct drm_encoder *encoder, - struct imx_drm_encoder **new_enc, - struct module *owner); -int imx_drm_remove_encoder(struct imx_drm_encoder *); - -struct imx_drm_connector; -int imx_drm_add_connector(struct drm_connector *connector, - struct imx_drm_connector **new_con, - struct module *owner); -int imx_drm_remove_connector(struct imx_drm_connector *); - void imx_drm_mode_config_init(struct drm_device *drm); struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb); @@ -63,8 +51,6 @@ int imx_drm_panel_format(struct drm_encoder *encoder, struct device_node; int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder); -int imx_drm_encoder_add_possible_crtcs(struct imx_drm_encoder *imx_drm_encoder, - struct device_node *np); int imx_drm_encoder_parse_of(struct drm_device *drm, struct drm_encoder *encoder, struct device_node *np); From 06c6b82bf717f1851ca78d0346e915e879061c69 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 11 Nov 2013 16:20:25 +0000 Subject: [PATCH 0424/1375] imx-drm: imx-drm-core: get rid of drm_mode_group_init_legacy_group() Since we're now operating like a conventional DRM driver, doing all the initialisation within the driver's ->load callback, we don't need to mess around with the mode groups - we can rely on the one in the DRM platform code. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index b27c42539e49..dd97412d6c8a 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -274,12 +274,6 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) drm_kms_helper_poll_init(drm); - /* setup the grouping for the legacy output */ - ret = drm_mode_group_init_legacy_group(drm, - &drm->primary->mode_group); - if (ret) - goto err_kms; - ret = drm_vblank_init(drm, MAX_CRTC); if (ret) goto err_kms; From ccec7f621de02c1a5b3765f74b50d9ab6145658e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 15:20:18 +0000 Subject: [PATCH 0425/1375] imx-drm: imx-drm-core: kill off mutex This mutex doesn't protect anything anymore; get rid of it. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index dd97412d6c8a..d5b82cb0cfae 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -40,14 +40,12 @@ struct imx_drm_device { struct drm_device *drm; struct device *dev; struct imx_drm_crtc *crtc[MAX_CRTC]; - struct mutex mutex; int pipes; struct drm_fbdev_cma *fbhelper; }; struct imx_drm_crtc { struct drm_crtc *crtc; - struct imx_drm_device *imxdrm; int pipe; struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; struct crtc_cookie cookie; @@ -270,8 +268,6 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) drm_mode_config_init(drm); - mutex_lock(&imxdrm->mutex); - drm_kms_helper_poll_init(drm); ret = drm_vblank_init(drm, MAX_CRTC); @@ -287,12 +283,10 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) platform_set_drvdata(drm->platformdev, drm); - mutex_unlock(&imxdrm->mutex); - /* Now try and bind all our sub-components */ ret = component_bind_all(drm->dev, drm); if (ret) - goto err_relock; + goto err_vblank; /* * All components are now added, we can publish the connector sysfs @@ -332,13 +326,11 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) err_unbind: component_unbind_all(drm->dev, drm); -err_relock: - mutex_lock(&imxdrm->mutex); +err_vblank: drm_vblank_cleanup(drm); err_kms: drm_kms_helper_poll_fini(drm); drm_mode_config_cleanup(drm); - mutex_unlock(&imxdrm->mutex); return ret; } @@ -358,8 +350,6 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, struct imx_drm_crtc *imx_drm_crtc; int ret; - mutex_lock(&imxdrm->mutex); - /* * The vblank arrays are dimensioned by MAX_CRTC - we can't * pass IDs greater than this to those functions. @@ -386,7 +376,6 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, imx_drm_crtc->cookie.id = id; imx_drm_crtc->mux_id = imx_drm_crtc->pipe; imx_drm_crtc->crtc = crtc; - imx_drm_crtc->imxdrm = imxdrm; imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc; @@ -402,8 +391,6 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, drm_crtc_init(drm, crtc, imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); - mutex_unlock(&imxdrm->mutex); - return 0; err_register: @@ -411,7 +398,6 @@ err_register: kfree(imx_drm_crtc); err_alloc: err_busy: - mutex_unlock(&imxdrm->mutex); return ret; } EXPORT_SYMBOL_GPL(imx_drm_add_crtc); @@ -421,16 +407,12 @@ EXPORT_SYMBOL_GPL(imx_drm_add_crtc); */ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) { - struct imx_drm_device *imxdrm = imx_drm_crtc->imxdrm; - - mutex_lock(&imxdrm->mutex); + struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private; drm_crtc_cleanup(imx_drm_crtc->crtc); imxdrm->crtc[imx_drm_crtc->pipe] = NULL; - mutex_unlock(&imxdrm->mutex); - kfree(imx_drm_crtc); return 0; @@ -657,8 +639,6 @@ static int __init imx_drm_init(void) if (!imx_drm_device) return -ENOMEM; - mutex_init(&imx_drm_device->mutex); - ret = platform_driver_register(&imx_drm_pdrv); if (ret) goto err_pdrv; From b85f2b5d879597708808ece7e5ebbfd6823e3f69 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 15:31:22 +0000 Subject: [PATCH 0426/1375] imx-drm: imx-drm-core: move allocation of imxdrm device to driver load function It is now no longer necessary to keep this structure around; we can allocate it upon DRM driver load and destroy it thereafter without affecting the other components now. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 47 ++++---------------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index d5b82cb0cfae..35c8f7cf6900 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -38,7 +38,6 @@ struct imx_drm_crtc; struct imx_drm_device { struct drm_device *drm; - struct device *dev; struct imx_drm_crtc *crtc[MAX_CRTC]; int pipes; struct drm_fbdev_cma *fbhelper; @@ -206,13 +205,6 @@ int imx_drm_connector_mode_valid(struct drm_connector *connector, } EXPORT_SYMBOL(imx_drm_connector_mode_valid); -static struct imx_drm_device *imx_drm_device; - -static struct imx_drm_device *__imx_drm_device(void) -{ - return imx_drm_device; -} - void imx_drm_connector_destroy(struct drm_connector *connector) { drm_sysfs_connector_remove(connector); @@ -236,10 +228,14 @@ static struct drm_mode_config_funcs imx_drm_mode_config_funcs = { */ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) { - struct imx_drm_device *imxdrm = __imx_drm_device(); + struct imx_drm_device *imxdrm; struct drm_connector *connector; int ret; + imxdrm = devm_kzalloc(drm->dev, sizeof(*imxdrm), GFP_KERNEL); + if (!imxdrm) + return -ENOMEM; + imxdrm->drm = drm; drm->dev_private = imxdrm; @@ -604,8 +600,6 @@ static int imx_drm_platform_probe(struct platform_device *pdev) if (ret) return ret; - imx_drm_device->dev = &pdev->dev; - return component_master_add(&pdev->dev, &imx_drm_ops); } @@ -630,36 +624,7 @@ static struct platform_driver imx_drm_pdrv = { .of_match_table = imx_drm_dt_ids, }, }; - -static int __init imx_drm_init(void) -{ - int ret; - - imx_drm_device = kzalloc(sizeof(*imx_drm_device), GFP_KERNEL); - if (!imx_drm_device) - return -ENOMEM; - - ret = platform_driver_register(&imx_drm_pdrv); - if (ret) - goto err_pdrv; - - return 0; - -err_pdrv: - kfree(imx_drm_device); - - return ret; -} - -static void __exit imx_drm_exit(void) -{ - platform_driver_unregister(&imx_drm_pdrv); - - kfree(imx_drm_device); -} - -module_init(imx_drm_init); -module_exit(imx_drm_exit); +module_platform_driver(imx_drm_pdrv); MODULE_AUTHOR("Sascha Hauer "); MODULE_DESCRIPTION("i.MX drm driver core"); From e7d6231e67b92b6a45921a57cca5cafcc47c7746 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 15:38:09 +0000 Subject: [PATCH 0427/1375] imx-drm: imx-drm-core: various cleanups Various cleanups are possible after the previous round of changes; these have no real functional bearing other than tidying up the code. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 47 ++++++++++---------------- drivers/staging/imx-drm/imx-drm.h | 5 ++- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 35c8f7cf6900..7939cea8311a 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -15,12 +15,12 @@ */ #include #include +#include +#include #include #include #include #include -#include -#include #include #include @@ -28,12 +28,6 @@ #define MAX_CRTC 4 -struct crtc_cookie { - void *cookie; - int id; - struct list_head list; -}; - struct imx_drm_crtc; struct imx_drm_device { @@ -47,7 +41,8 @@ struct imx_drm_crtc { struct drm_crtc *crtc; int pipe; struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; - struct crtc_cookie cookie; + void *cookie; + int id; int mux_id; }; @@ -271,9 +266,9 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) goto err_kms; /* - * with vblank_disable_allowed = true, vblank interrupt will be disabled - * by drm timer once a current process gives up ownership of - * vblank event.(after drm_vblank_put function is called) + * with vblank_disable_allowed = true, vblank interrupt will be + * disabled by drm timer once a current process gives up ownership + * of vblank event. (after drm_vblank_put function is called) */ drm->vblank_disable_allowed = true; @@ -350,26 +345,20 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, * The vblank arrays are dimensioned by MAX_CRTC - we can't * pass IDs greater than this to those functions. */ - if (imxdrm->pipes >= MAX_CRTC) { - ret = -EINVAL; - goto err_busy; - } + if (imxdrm->pipes >= MAX_CRTC) + return -EINVAL; - if (imxdrm->drm->open_count) { - ret = -EBUSY; - goto err_busy; - } + if (imxdrm->drm->open_count) + return -EBUSY; imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL); - if (!imx_drm_crtc) { - ret = -ENOMEM; - goto err_alloc; - } + if (!imx_drm_crtc) + return -ENOMEM; imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; imx_drm_crtc->pipe = imxdrm->pipes++; - imx_drm_crtc->cookie.cookie = cookie; - imx_drm_crtc->cookie.id = id; + imx_drm_crtc->cookie = cookie; + imx_drm_crtc->id = id; imx_drm_crtc->mux_id = imx_drm_crtc->pipe; imx_drm_crtc->crtc = crtc; @@ -392,8 +381,6 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, err_register: imxdrm->crtc[imx_drm_crtc->pipe] = NULL; kfree(imx_drm_crtc); -err_alloc: -err_busy: return ret; } EXPORT_SYMBOL_GPL(imx_drm_add_crtc); @@ -429,8 +416,8 @@ static uint32_t imx_drm_find_crtc_mask(struct imx_drm_device *imxdrm, for (i = 0; i < MAX_CRTC; i++) { struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[i]; - if (imx_drm_crtc && imx_drm_crtc->cookie.id == id && - imx_drm_crtc->cookie.cookie == cookie) + if (imx_drm_crtc && imx_drm_crtc->id == id && + imx_drm_crtc->cookie == cookie) return drm_crtc_mask(imx_drm_crtc->crtc); } diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index ae9c96d181fa..aa2102866689 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -5,14 +5,15 @@ #define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3') +struct device_node; struct drm_crtc; struct drm_connector; struct drm_device; struct drm_display_mode; struct drm_encoder; -struct imx_drm_crtc; struct drm_fbdev_cma; struct drm_framebuffer; +struct imx_drm_crtc; struct platform_device; int imx_drm_crtc_id(struct imx_drm_crtc *crtc); @@ -48,8 +49,6 @@ int imx_drm_panel_format_pins(struct drm_encoder *encoder, int imx_drm_panel_format(struct drm_encoder *encoder, u32 interface_pix_fmt); -struct device_node; - int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder); int imx_drm_encoder_parse_of(struct drm_device *drm, struct drm_encoder *encoder, struct device_node *np); From 3e68439bf0adc7b11e479d27919b93453d7f9307 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 22:18:40 +0000 Subject: [PATCH 0428/1375] imx-drm: imx-drm-core: add core hotplug connector support Add core imx-drm support for hotplug connector support. We need to setup the poll helper after we've setup the connectors; the helper scans the connectors to determine their capabilities. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 7939cea8311a..dcba51853e8a 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -69,7 +69,11 @@ static int imx_drm_driver_unload(struct drm_device *drm) { #if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) struct imx_drm_device *imxdrm = drm->dev_private; +#endif + drm_kms_helper_poll_fini(drm); + +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) if (imxdrm->fbhelper) drm_fbdev_cma_fini(imxdrm->fbhelper); #endif @@ -77,7 +81,6 @@ static int imx_drm_driver_unload(struct drm_device *drm) component_unbind_all(drm->dev, drm); drm_vblank_cleanup(drm); - drm_kms_helper_poll_fini(drm); drm_mode_config_cleanup(drm); return 0; @@ -213,8 +216,18 @@ void imx_drm_encoder_destroy(struct drm_encoder *encoder) } EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); +static void imx_drm_output_poll_changed(struct drm_device *drm) +{ +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) + struct imx_drm_device *imxdrm = drm->dev_private; + + drm_fbdev_cma_hotplug_event(imxdrm->fbhelper); +#endif +} + static struct drm_mode_config_funcs imx_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, + .output_poll_changed = imx_drm_output_poll_changed, }; /* @@ -259,8 +272,6 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) drm_mode_config_init(drm); - drm_kms_helper_poll_init(drm); - ret = drm_vblank_init(drm, MAX_CRTC); if (ret) goto err_kms; @@ -313,6 +324,9 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) goto err_unbind; } #endif + + drm_kms_helper_poll_init(drm); + return 0; err_unbind: @@ -320,7 +334,6 @@ err_unbind: err_vblank: drm_vblank_cleanup(drm); err_kms: - drm_kms_helper_poll_fini(drm); drm_mode_config_cleanup(drm); return ret; From d94905e019acce960feeda1f92a9427fbe45ebbe Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 3 Nov 2013 22:23:24 +0000 Subject: [PATCH 0429/1375] imx-drm: imx-hdmi: add hotplug support to HDMI component Add hotplug support. We have to make the interrupt handler threaded so we can call drm_helper_hpd_irq_event(). Keeping in mind that we will want to share the interrupt with other HDMI interface drivers (eg, audio and CEC) put the groundwork in now for that, rather than just using IRQF_ONESHOT. Also, we must not call drm_helper_hpd_irq_event() until we have fully setup the connector; keep the interrupt(s) muted until after that point. Acked-by: Philipp Zabel Acked-by: Shawn Guo Reviewed-by: Fabio Estevam Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 40 ++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 8c586453df11..ab16aba7788d 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -120,6 +120,8 @@ struct imx_hdmi { struct clk *isfr_clk; struct clk *iahb_clk; + enum drm_connector_status connector_status; + struct hdmi_data_info hdmi_data; int vic; @@ -1301,9 +1303,6 @@ static int imx_hdmi_fb_registered(struct imx_hdmi *hdmi) /* Clear Hotplug interrupts */ hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD, HDMI_IH_PHY_STAT0); - /* Unmute interrupts */ - hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0); - return 0; } @@ -1372,8 +1371,9 @@ static void imx_hdmi_poweroff(struct imx_hdmi *hdmi) static enum drm_connector_status imx_hdmi_connector_detect(struct drm_connector *connector, bool force) { - /* FIXME */ - return connector_status_connected; + struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi, + connector); + return hdmi->connector_status; } static int imx_hdmi_connector_get_modes(struct drm_connector *connector) @@ -1487,6 +1487,18 @@ static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = { .best_encoder = imx_hdmi_connector_best_encoder, }; +static irqreturn_t imx_hdmi_hardirq(int irq, void *dev_id) +{ + struct imx_hdmi *hdmi = dev_id; + u8 intr_stat; + + intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); + if (intr_stat) + hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); + + return intr_stat ? IRQ_WAKE_THREAD : IRQ_NONE; +} + static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) { struct imx_hdmi *hdmi = dev_id; @@ -1503,17 +1515,21 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) hdmi_modb(hdmi, 0, HDMI_PHY_HPD, HDMI_PHY_POL0); + hdmi->connector_status = connector_status_connected; imx_hdmi_poweron(hdmi); } else { dev_dbg(hdmi->dev, "EVENT=plugout\n"); hdmi_modb(hdmi, HDMI_PHY_HPD, HDMI_PHY_HPD, HDMI_PHY_POL0); + hdmi->connector_status = connector_status_disconnected; imx_hdmi_poweroff(hdmi); } + drm_helper_hpd_irq_event(hdmi->connector.dev); } hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0); + hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0); return IRQ_HANDLED; } @@ -1527,6 +1543,8 @@ static int imx_hdmi_register(struct drm_device *drm, struct imx_hdmi *hdmi) if (ret) return ret; + hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; + drm_encoder_helper_add(&hdmi->encoder, &imx_hdmi_encoder_helper_funcs); drm_encoder_init(drm, &hdmi->encoder, &imx_hdmi_encoder_funcs, DRM_MODE_ENCODER_TMDS); @@ -1578,6 +1596,7 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) return -ENOMEM; hdmi->dev = dev; + hdmi->connector_status = connector_status_disconnected; hdmi->sample_rate = 48000; hdmi->ratio = 100; @@ -1601,8 +1620,9 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) if (irq < 0) return -EINVAL; - ret = devm_request_irq(dev, irq, imx_hdmi_irq, 0, - dev_name(dev), hdmi); + ret = devm_request_threaded_irq(dev, irq, imx_hdmi_hardirq, + imx_hdmi_irq, IRQF_SHARED, + dev_name(dev), hdmi); if (ret) return ret; @@ -1678,6 +1698,9 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) if (ret) goto err_iahb; + /* Unmute interrupts */ + hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0); + dev_set_drvdata(dev, hdmi); return 0; @@ -1695,6 +1718,9 @@ static void imx_hdmi_unbind(struct device *dev, struct device *master, { struct imx_hdmi *hdmi = dev_get_drvdata(dev); + /* Disable all interrupts */ + hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); + hdmi->connector.funcs->destroy(&hdmi->connector); hdmi->encoder.funcs->destroy(&hdmi->encoder); From df24a2eaa1e2de82d3033e1f37f17ad9c9a1c58e Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Fri, 21 Feb 2014 14:40:25 -0800 Subject: [PATCH 0430/1375] staging: binder: Fix ABI for 64bit Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BC_REQUEST_DEATH_NOTIFICATION and BC_CLEAR_DEATH_NOTIFICATION were defined with the wrong structure that did not match the code. Since a binder pointer and handle are the same size on 32 bit systems, this change does not affect them. The two commands claimed they were using struct binder_ptr_cookie but they are using a 32bit handle and a pointer. The main purpose of this patch is to add the binder_handle_cookie struct so the service manager does not have to define its own version (libbinder writes one field at a time so it does not use the struct). On 32bit systems the payload size is the same as the size of struct binder_ptr_cookie. On 64bit systems, the size does differ, and the ioctl number does change. However, there are no known 64bit users of this interface, and any 64bit systems will need the following patch to run 32 bit processes anyway, so it is not expected that anyone will ship a 64bit system without this change, so this change should not affect any existing systems. Cc: Colin Cross Cc: Arve Hjønnevåg Cc: Serban Constantinescu Cc: Android Kernel Team Signed-off-by: Serban Constantinescu [jstultz: Few 80+ col fixes for checkpatch, improved commit message with help from Serban, and included rational from Arve's email] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/uapi/binder.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/uapi/binder.h b/drivers/staging/android/uapi/binder.h index 2b1eb8106d58..4071fcffa83c 100644 --- a/drivers/staging/android/uapi/binder.h +++ b/drivers/staging/android/uapi/binder.h @@ -152,6 +152,11 @@ struct binder_ptr_cookie { void *cookie; }; +struct binder_handle_cookie { + __u32 handle; + void *cookie; +} __attribute__((packed)); + struct binder_pri_desc { __s32 priority; __u32 desc; @@ -308,15 +313,17 @@ enum binder_driver_command_protocol { * of looping threads it has available. */ - BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_ptr_cookie), + BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, + struct binder_handle_cookie), /* - * void *: ptr to binder + * int: handle * void *: cookie */ - BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_ptr_cookie), + BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, + struct binder_handle_cookie), /* - * void *: ptr to binder + * int: handle * void *: cookie */ From da49889deb34d351cdd113f9d1607dbb830cb5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Date: Fri, 21 Feb 2014 14:40:26 -0800 Subject: [PATCH 0431/1375] staging: binder: Support concurrent 32 bit and 64 bit processes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For 64bit systems we want to use the same binder interface for 32bit and 64bit processes. Thus the size and the layout of the structures passed between the kernel and the userspace has to be the same for both 32 and 64bit processes. This change replaces all the uses of void* and size_t with binder_uintptr_t and binder_size_t. These are then typedefed to specific sizes depending on the use of the interface, as follows: * __u32 - on legacy 32bit only userspace * __u64 - on mixed 32/64bit userspace where all processes use the same interface. This change also increments the BINDER_CURRENT_PROTOCOL_VERSION to 8 and hooks the compat_ioctl entry for the mixed 32/64bit Android userspace. This patch also provides a CONFIG_ANDROID_BINDER_IPC_32BIT option for compatability, which if set which enables the old protocol, setting BINDER_CURRENT_PROTOCOL_VERSION to 7, on 32 bit systems. Please note that all 64bit kernels will use the 64bit Binder ABI. Cc: Colin Cross Cc: Arve Hjønnevåg Cc: Serban Constantinescu Cc: Android Kernel Team Signed-off-by: Arve Hjønnevåg [jstultz: Merged with upstream type changes. Various whitespace fixes and longer Kconfig description for checkpatch. Included improved commit message from Serban (with a few tweaks).] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Kconfig | 12 ++ drivers/staging/android/binder.c | 268 ++++++++++++++----------- drivers/staging/android/binder.h | 4 + drivers/staging/android/binder_trace.h | 14 +- drivers/staging/android/uapi/binder.h | 64 +++--- 5 files changed, 213 insertions(+), 149 deletions(-) diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index b91c758883bf..3559690273aa 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -20,6 +20,18 @@ config ANDROID_BINDER_IPC Android process, using Binder to identify, invoke and pass arguments between said processes. +config ANDROID_BINDER_IPC_32BIT + bool "Use old 32-bit binder api" + depends on !64BIT + ---help--- + The Binder API has been changed to support both 32 and 64bit + applications in a mixed environment. + + Enable this to support an old 32-bit Android user-space (v4.4 and + earlier). + + Note that enabling this will break newer Android user-space. + config ASHMEM bool "Enable the Anonymous Shared Memory Subsystem" default n diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 1432d956769c..cfe4bc8f05cb 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -228,8 +228,8 @@ struct binder_node { int internal_strong_refs; int local_weak_refs; int local_strong_refs; - void __user *ptr; - void __user *cookie; + binder_uintptr_t ptr; + binder_uintptr_t cookie; unsigned has_strong_ref:1; unsigned pending_strong_ref:1; unsigned has_weak_ref:1; @@ -242,7 +242,7 @@ struct binder_node { struct binder_ref_death { struct binder_work work; - void __user *cookie; + binder_uintptr_t cookie; }; struct binder_ref { @@ -515,14 +515,14 @@ static void binder_insert_allocated_buffer(struct binder_proc *proc, } static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc, - void __user *user_ptr) + uintptr_t user_ptr) { struct rb_node *n = proc->allocated_buffers.rb_node; struct binder_buffer *buffer; struct binder_buffer *kern_ptr; - kern_ptr = user_ptr - proc->user_buffer_offset - - offsetof(struct binder_buffer, data); + kern_ptr = (struct binder_buffer *)(user_ptr - proc->user_buffer_offset + - offsetof(struct binder_buffer, data)); while (n) { buffer = rb_entry(n, struct binder_buffer, rb_node); @@ -856,7 +856,7 @@ static void binder_free_buf(struct binder_proc *proc, } static struct binder_node *binder_get_node(struct binder_proc *proc, - void __user *ptr) + binder_uintptr_t ptr) { struct rb_node *n = proc->nodes.rb_node; struct binder_node *node; @@ -875,8 +875,8 @@ static struct binder_node *binder_get_node(struct binder_proc *proc, } static struct binder_node *binder_new_node(struct binder_proc *proc, - void __user *ptr, - void __user *cookie) + binder_uintptr_t ptr, + binder_uintptr_t cookie) { struct rb_node **p = &proc->nodes.rb_node; struct rb_node *parent = NULL; @@ -908,9 +908,9 @@ static struct binder_node *binder_new_node(struct binder_proc *proc, INIT_LIST_HEAD(&node->work.entry); INIT_LIST_HEAD(&node->async_todo); binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d:%d node %d u%p c%p created\n", + "%d:%d node %d u%016llx c%016llx created\n", proc->pid, current->pid, node->debug_id, - node->ptr, node->cookie); + (u64)node->ptr, (u64)node->cookie); return node; } @@ -1226,9 +1226,9 @@ static void binder_send_failed_reply(struct binder_transaction *t, static void binder_transaction_buffer_release(struct binder_proc *proc, struct binder_buffer *buffer, - size_t *failed_at) + binder_size_t *failed_at) { - size_t *offp, *off_end; + binder_size_t *offp, *off_end; int debug_id = buffer->debug_id; binder_debug(BINDER_DEBUG_TRANSACTION, @@ -1239,7 +1239,8 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, if (buffer->target_node) binder_dec_node(buffer->target_node, 1, 0); - offp = (size_t *)(buffer->data + ALIGN(buffer->data_size, sizeof(void *))); + offp = (binder_size_t *)(buffer->data + + ALIGN(buffer->data_size, sizeof(void *))); if (failed_at) off_end = failed_at; else @@ -1249,8 +1250,8 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, if (*offp > buffer->data_size - sizeof(*fp) || buffer->data_size < sizeof(*fp) || !IS_ALIGNED(*offp, sizeof(u32))) { - pr_err("transaction release %d bad offset %zd, size %zd\n", - debug_id, *offp, buffer->data_size); + pr_err("transaction release %d bad offset %lld, size %zd\n", + debug_id, (u64)*offp, buffer->data_size); continue; } fp = (struct flat_binder_object *)(buffer->data + *offp); @@ -1259,13 +1260,13 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, case BINDER_TYPE_WEAK_BINDER: { struct binder_node *node = binder_get_node(proc, fp->binder); if (node == NULL) { - pr_err("transaction release %d bad node %p\n", - debug_id, fp->binder); + pr_err("transaction release %d bad node %016llx\n", + debug_id, (u64)fp->binder); break; } binder_debug(BINDER_DEBUG_TRANSACTION, - " node %d u%p\n", - node->debug_id, node->ptr); + " node %d u%016llx\n", + node->debug_id, (u64)node->ptr); binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0); } break; case BINDER_TYPE_HANDLE: @@ -1303,7 +1304,7 @@ static void binder_transaction(struct binder_proc *proc, { struct binder_transaction *t; struct binder_work *tcomplete; - size_t *offp, *off_end; + binder_size_t *offp, *off_end; struct binder_proc *target_proc; struct binder_thread *target_thread = NULL; struct binder_node *target_node = NULL; @@ -1432,18 +1433,20 @@ static void binder_transaction(struct binder_proc *proc, if (reply) binder_debug(BINDER_DEBUG_TRANSACTION, - "%d:%d BC_REPLY %d -> %d:%d, data %p-%p size %zd-%zd\n", + "%d:%d BC_REPLY %d -> %d:%d, data %016llx-%016llx size %lld-%lld\n", proc->pid, thread->pid, t->debug_id, target_proc->pid, target_thread->pid, - tr->data.ptr.buffer, tr->data.ptr.offsets, - tr->data_size, tr->offsets_size); + (u64)tr->data.ptr.buffer, + (u64)tr->data.ptr.offsets, + (u64)tr->data_size, (u64)tr->offsets_size); else binder_debug(BINDER_DEBUG_TRANSACTION, - "%d:%d BC_TRANSACTION %d -> %d - node %d, data %p-%p size %zd-%zd\n", + "%d:%d BC_TRANSACTION %d -> %d - node %d, data %016llx-%016llx size %lld-%lld\n", proc->pid, thread->pid, t->debug_id, target_proc->pid, target_node->debug_id, - tr->data.ptr.buffer, tr->data.ptr.offsets, - tr->data_size, tr->offsets_size); + (u64)tr->data.ptr.buffer, + (u64)tr->data.ptr.offsets, + (u64)tr->data_size, (u64)tr->offsets_size); if (!reply && !(tr->flags & TF_ONE_WAY)) t->from = thread; @@ -1472,23 +1475,26 @@ static void binder_transaction(struct binder_proc *proc, if (target_node) binder_inc_node(target_node, 1, 0, NULL); - offp = (size_t *)(t->buffer->data + ALIGN(tr->data_size, sizeof(void *))); + offp = (binder_size_t *)(t->buffer->data + + ALIGN(tr->data_size, sizeof(void *))); - if (copy_from_user(t->buffer->data, tr->data.ptr.buffer, tr->data_size)) { + if (copy_from_user(t->buffer->data, (const void __user *)(uintptr_t) + tr->data.ptr.buffer, tr->data_size)) { binder_user_error("%d:%d got transaction with invalid data ptr\n", proc->pid, thread->pid); return_error = BR_FAILED_REPLY; goto err_copy_data_failed; } - if (copy_from_user(offp, tr->data.ptr.offsets, tr->offsets_size)) { + if (copy_from_user(offp, (const void __user *)(uintptr_t) + tr->data.ptr.offsets, tr->offsets_size)) { binder_user_error("%d:%d got transaction with invalid offsets ptr\n", proc->pid, thread->pid); return_error = BR_FAILED_REPLY; goto err_copy_data_failed; } - if (!IS_ALIGNED(tr->offsets_size, sizeof(size_t))) { - binder_user_error("%d:%d got transaction with invalid offsets size, %zd\n", - proc->pid, thread->pid, tr->offsets_size); + if (!IS_ALIGNED(tr->offsets_size, sizeof(binder_size_t))) { + binder_user_error("%d:%d got transaction with invalid offsets size, %lld\n", + proc->pid, thread->pid, (u64)tr->offsets_size); return_error = BR_FAILED_REPLY; goto err_bad_offset; } @@ -1498,8 +1504,8 @@ static void binder_transaction(struct binder_proc *proc, if (*offp > t->buffer->data_size - sizeof(*fp) || t->buffer->data_size < sizeof(*fp) || !IS_ALIGNED(*offp, sizeof(u32))) { - binder_user_error("%d:%d got transaction with invalid offset, %zd\n", - proc->pid, thread->pid, *offp); + binder_user_error("%d:%d got transaction with invalid offset, %lld\n", + proc->pid, thread->pid, (u64)*offp); return_error = BR_FAILED_REPLY; goto err_bad_offset; } @@ -1519,10 +1525,10 @@ static void binder_transaction(struct binder_proc *proc, node->accept_fds = !!(fp->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS); } if (fp->cookie != node->cookie) { - binder_user_error("%d:%d sending u%p node %d, cookie mismatch %p != %p\n", + binder_user_error("%d:%d sending u%016llx node %d, cookie mismatch %016llx != %016llx\n", proc->pid, thread->pid, - fp->binder, node->debug_id, - fp->cookie, node->cookie); + (u64)fp->binder, node->debug_id, + (u64)fp->cookie, (u64)node->cookie); goto err_binder_get_ref_for_node_failed; } ref = binder_get_ref_for_node(target_proc, node); @@ -1540,9 +1546,9 @@ static void binder_transaction(struct binder_proc *proc, trace_binder_transaction_node_to_ref(t, node, ref); binder_debug(BINDER_DEBUG_TRANSACTION, - " node %d u%p -> ref %d desc %d\n", - node->debug_id, node->ptr, ref->debug_id, - ref->desc); + " node %d u%016llx -> ref %d desc %d\n", + node->debug_id, (u64)node->ptr, + ref->debug_id, ref->desc); } break; case BINDER_TYPE_HANDLE: case BINDER_TYPE_WEAK_HANDLE: { @@ -1564,9 +1570,9 @@ static void binder_transaction(struct binder_proc *proc, binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL); trace_binder_transaction_ref_to_node(t, ref); binder_debug(BINDER_DEBUG_TRANSACTION, - " ref %d desc %d -> node %d u%p\n", + " ref %d desc %d -> node %d u%016llx\n", ref->debug_id, ref->desc, ref->node->debug_id, - ref->node->ptr); + (u64)ref->node->ptr); } else { struct binder_ref *new_ref; new_ref = binder_get_ref_for_node(target_proc, ref->node); @@ -1682,9 +1688,9 @@ err_dead_binder: err_invalid_target_handle: err_no_context_mgr_node: binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "%d:%d transaction failed %d, size %zd-%zd\n", + "%d:%d transaction failed %d, size %lld-%lld\n", proc->pid, thread->pid, return_error, - tr->data_size, tr->offsets_size); + (u64)tr->data_size, (u64)tr->offsets_size); { struct binder_transaction_log_entry *fe; @@ -1702,9 +1708,11 @@ err_no_context_mgr_node: static int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread, - void __user *buffer, size_t size, size_t *consumed) + binder_uintptr_t binder_buffer, size_t size, + binder_size_t *consumed) { uint32_t cmd; + void __user *buffer = (void __user *)(uintptr_t)binder_buffer; void __user *ptr = buffer + *consumed; void __user *end = buffer + size; @@ -1773,33 +1781,33 @@ static int binder_thread_write(struct binder_proc *proc, } case BC_INCREFS_DONE: case BC_ACQUIRE_DONE: { - void __user *node_ptr; - void __user *cookie; + binder_uintptr_t node_ptr; + binder_uintptr_t cookie; struct binder_node *node; - if (get_user(node_ptr, (void * __user *)ptr)) + if (get_user(node_ptr, (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); - if (get_user(cookie, (void * __user *)ptr)) + ptr += sizeof(binder_uintptr_t); + if (get_user(cookie, (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); + ptr += sizeof(binder_uintptr_t); node = binder_get_node(proc, node_ptr); if (node == NULL) { - binder_user_error("%d:%d %s u%p no match\n", + binder_user_error("%d:%d %s u%016llx no match\n", proc->pid, thread->pid, cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", - node_ptr); + (u64)node_ptr); break; } if (cookie != node->cookie) { - binder_user_error("%d:%d %s u%p node %d cookie mismatch %p != %p\n", + binder_user_error("%d:%d %s u%016llx node %d cookie mismatch %016llx != %016llx\n", proc->pid, thread->pid, cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", - node_ptr, node->debug_id, - cookie, node->cookie); + (u64)node_ptr, node->debug_id, + (u64)cookie, (u64)node->cookie); break; } if (cmd == BC_ACQUIRE_DONE) { @@ -1835,27 +1843,28 @@ static int binder_thread_write(struct binder_proc *proc, return -EINVAL; case BC_FREE_BUFFER: { - void __user *data_ptr; + binder_uintptr_t data_ptr; struct binder_buffer *buffer; - if (get_user(data_ptr, (void * __user *)ptr)) + if (get_user(data_ptr, (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); + ptr += sizeof(binder_uintptr_t); buffer = binder_buffer_lookup(proc, data_ptr); if (buffer == NULL) { - binder_user_error("%d:%d BC_FREE_BUFFER u%p no match\n", - proc->pid, thread->pid, data_ptr); + binder_user_error("%d:%d BC_FREE_BUFFER u%016llx no match\n", + proc->pid, thread->pid, (u64)data_ptr); break; } if (!buffer->allow_user_free) { - binder_user_error("%d:%d BC_FREE_BUFFER u%p matched unreturned buffer\n", - proc->pid, thread->pid, data_ptr); + binder_user_error("%d:%d BC_FREE_BUFFER u%016llx matched unreturned buffer\n", + proc->pid, thread->pid, (u64)data_ptr); break; } binder_debug(BINDER_DEBUG_FREE_BUFFER, - "%d:%d BC_FREE_BUFFER u%p found buffer %d for %s transaction\n", - proc->pid, thread->pid, data_ptr, buffer->debug_id, + "%d:%d BC_FREE_BUFFER u%016llx found buffer %d for %s transaction\n", + proc->pid, thread->pid, (u64)data_ptr, + buffer->debug_id, buffer->transaction ? "active" : "finished"); if (buffer->transaction) { @@ -1925,16 +1934,16 @@ static int binder_thread_write(struct binder_proc *proc, case BC_REQUEST_DEATH_NOTIFICATION: case BC_CLEAR_DEATH_NOTIFICATION: { uint32_t target; - void __user *cookie; + binder_uintptr_t cookie; struct binder_ref *ref; struct binder_ref_death *death; if (get_user(target, (uint32_t __user *)ptr)) return -EFAULT; ptr += sizeof(uint32_t); - if (get_user(cookie, (void __user * __user *)ptr)) + if (get_user(cookie, (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); + ptr += sizeof(binder_uintptr_t); ref = binder_get_ref(proc, target); if (ref == NULL) { binder_user_error("%d:%d %s invalid ref %d\n", @@ -1947,12 +1956,12 @@ static int binder_thread_write(struct binder_proc *proc, } binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, - "%d:%d %s %p ref %d desc %d s %d w %d for node %d\n", + "%d:%d %s %016llx ref %d desc %d s %d w %d for node %d\n", proc->pid, thread->pid, cmd == BC_REQUEST_DEATH_NOTIFICATION ? "BC_REQUEST_DEATH_NOTIFICATION" : "BC_CLEAR_DEATH_NOTIFICATION", - cookie, ref->debug_id, ref->desc, + (u64)cookie, ref->debug_id, ref->desc, ref->strong, ref->weak, ref->node->debug_id); if (cmd == BC_REQUEST_DEATH_NOTIFICATION) { @@ -1990,9 +1999,10 @@ static int binder_thread_write(struct binder_proc *proc, } death = ref->death; if (death->cookie != cookie) { - binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification cookie mismatch %p != %p\n", + binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification cookie mismatch %016llx != %016llx\n", proc->pid, thread->pid, - death->cookie, cookie); + (u64)death->cookie, + (u64)cookie); break; } ref->death = NULL; @@ -2012,9 +2022,9 @@ static int binder_thread_write(struct binder_proc *proc, } break; case BC_DEAD_BINDER_DONE: { struct binder_work *w; - void __user *cookie; + binder_uintptr_t cookie; struct binder_ref_death *death = NULL; - if (get_user(cookie, (void __user * __user *)ptr)) + if (get_user(cookie, (binder_uintptr_t __user *)ptr)) return -EFAULT; ptr += sizeof(void *); @@ -2026,11 +2036,12 @@ static int binder_thread_write(struct binder_proc *proc, } } binder_debug(BINDER_DEBUG_DEAD_BINDER, - "%d:%d BC_DEAD_BINDER_DONE %p found %p\n", - proc->pid, thread->pid, cookie, death); + "%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n", + proc->pid, thread->pid, (u64)cookie, + death); if (death == NULL) { - binder_user_error("%d:%d BC_DEAD_BINDER_DONE %p not found\n", - proc->pid, thread->pid, cookie); + binder_user_error("%d:%d BC_DEAD_BINDER_DONE %016llx not found\n", + proc->pid, thread->pid, (u64)cookie); break; } @@ -2082,9 +2093,10 @@ static int binder_has_thread_work(struct binder_thread *thread) static int binder_thread_read(struct binder_proc *proc, struct binder_thread *thread, - void __user *buffer, size_t size, - size_t *consumed, int non_block) + binder_uintptr_t binder_buffer, size_t size, + binder_size_t *consumed, int non_block) { + void __user *buffer = (void __user *)(uintptr_t)binder_buffer; void __user *ptr = buffer + *consumed; void __user *end = buffer + size; @@ -2229,32 +2241,40 @@ retry: if (put_user(cmd, (uint32_t __user *)ptr)) return -EFAULT; ptr += sizeof(uint32_t); - if (put_user(node->ptr, (void * __user *)ptr)) + if (put_user(node->ptr, + (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); - if (put_user(node->cookie, (void * __user *)ptr)) + ptr += sizeof(binder_uintptr_t); + if (put_user(node->cookie, + (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); + ptr += sizeof(binder_uintptr_t); binder_stat_br(proc, thread, cmd); binder_debug(BINDER_DEBUG_USER_REFS, - "%d:%d %s %d u%p c%p\n", - proc->pid, thread->pid, cmd_name, node->debug_id, node->ptr, node->cookie); + "%d:%d %s %d u%016llx c%016llx\n", + proc->pid, thread->pid, cmd_name, + node->debug_id, + (u64)node->ptr, (u64)node->cookie); } else { list_del_init(&w->entry); if (!weak && !strong) { binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d:%d node %d u%p c%p deleted\n", - proc->pid, thread->pid, node->debug_id, - node->ptr, node->cookie); + "%d:%d node %d u%016llx c%016llx deleted\n", + proc->pid, thread->pid, + node->debug_id, + (u64)node->ptr, + (u64)node->cookie); rb_erase(&node->rb_node, &proc->nodes); kfree(node); binder_stats_deleted(BINDER_STAT_NODE); } else { binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d:%d node %d u%p c%p state unchanged\n", - proc->pid, thread->pid, node->debug_id, node->ptr, - node->cookie); + "%d:%d node %d u%016llx c%016llx state unchanged\n", + proc->pid, thread->pid, + node->debug_id, + (u64)node->ptr, + (u64)node->cookie); } } } break; @@ -2272,17 +2292,18 @@ retry: if (put_user(cmd, (uint32_t __user *)ptr)) return -EFAULT; ptr += sizeof(uint32_t); - if (put_user(death->cookie, (void * __user *)ptr)) + if (put_user(death->cookie, + (binder_uintptr_t __user *)ptr)) return -EFAULT; - ptr += sizeof(void *); + ptr += sizeof(binder_uintptr_t); binder_stat_br(proc, thread, cmd); binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, - "%d:%d %s %p\n", + "%d:%d %s %016llx\n", proc->pid, thread->pid, cmd == BR_DEAD_BINDER ? "BR_DEAD_BINDER" : "BR_CLEAR_DEATH_NOTIFICATION_DONE", - death->cookie); + (u64)death->cookie); if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) { list_del(&w->entry); @@ -2312,8 +2333,8 @@ retry: binder_set_nice(target_node->min_priority); cmd = BR_TRANSACTION; } else { - tr.target.ptr = NULL; - tr.cookie = NULL; + tr.target.ptr = 0; + tr.cookie = 0; cmd = BR_REPLY; } tr.code = t->code; @@ -2330,8 +2351,9 @@ retry: tr.data_size = t->buffer->data_size; tr.offsets_size = t->buffer->offsets_size; - tr.data.ptr.buffer = (void *)t->buffer->data + - proc->user_buffer_offset; + tr.data.ptr.buffer = (binder_uintptr_t)( + (uintptr_t)t->buffer->data + + proc->user_buffer_offset); tr.data.ptr.offsets = tr.data.ptr.buffer + ALIGN(t->buffer->data_size, sizeof(void *)); @@ -2346,14 +2368,14 @@ retry: trace_binder_transaction_received(t); binder_stat_br(proc, thread, cmd); binder_debug(BINDER_DEBUG_TRANSACTION, - "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %p-%p\n", + "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n", proc->pid, thread->pid, (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" : "BR_REPLY", t->debug_id, t->from ? t->from->proc->pid : 0, t->from ? t->from->pid : 0, cmd, t->buffer->data_size, t->buffer->offsets_size, - tr.data.ptr.buffer, tr.data.ptr.offsets); + (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets); list_del(&t->work.entry); t->buffer->allow_user_free = 1; @@ -2423,8 +2445,8 @@ static void binder_release_work(struct list_head *list) death = container_of(w, struct binder_ref_death, work); binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, - "undelivered death notification, %p\n", - death->cookie); + "undelivered death notification, %016llx\n", + (u64)death->cookie); kfree(death); binder_stats_deleted(BINDER_STAT_DEATH); } break; @@ -2580,12 +2602,16 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto err; } binder_debug(BINDER_DEBUG_READ_WRITE, - "%d:%d write %zd at %016lx, read %zd at %016lx\n", - proc->pid, thread->pid, bwr.write_size, - bwr.write_buffer, bwr.read_size, bwr.read_buffer); + "%d:%d write %lld at %016llx, read %lld at %016llx\n", + proc->pid, thread->pid, + (u64)bwr.write_size, (u64)bwr.write_buffer, + (u64)bwr.read_size, (u64)bwr.read_buffer); if (bwr.write_size > 0) { - ret = binder_thread_write(proc, thread, (void __user *)bwr.write_buffer, bwr.write_size, &bwr.write_consumed); + ret = binder_thread_write(proc, thread, + bwr.write_buffer, + bwr.write_size, + &bwr.write_consumed); trace_binder_write_done(ret); if (ret < 0) { bwr.read_consumed = 0; @@ -2595,7 +2621,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } } if (bwr.read_size > 0) { - ret = binder_thread_read(proc, thread, (void __user *)bwr.read_buffer, bwr.read_size, &bwr.read_consumed, filp->f_flags & O_NONBLOCK); + ret = binder_thread_read(proc, thread, bwr.read_buffer, + bwr.read_size, + &bwr.read_consumed, + filp->f_flags & O_NONBLOCK); trace_binder_read_done(ret); if (!list_empty(&proc->todo)) wake_up_interruptible(&proc->wait); @@ -2606,9 +2635,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } } binder_debug(BINDER_DEBUG_READ_WRITE, - "%d:%d wrote %zd of %zd, read return %zd of %zd\n", - proc->pid, thread->pid, bwr.write_consumed, bwr.write_size, - bwr.read_consumed, bwr.read_size); + "%d:%d wrote %lld of %lld, read return %lld of %lld\n", + proc->pid, thread->pid, + (u64)bwr.write_consumed, (u64)bwr.write_size, + (u64)bwr.read_consumed, (u64)bwr.read_size); if (copy_to_user(ubuf, &bwr, sizeof(bwr))) { ret = -EFAULT; goto err; @@ -2637,7 +2667,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } } else binder_context_mgr_uid = current->cred->euid; - binder_context_mgr_node = binder_new_node(proc, NULL, NULL); + binder_context_mgr_node = binder_new_node(proc, 0, 0); if (binder_context_mgr_node == NULL) { ret = -ENOMEM; goto err; @@ -3132,8 +3162,9 @@ static void print_binder_work(struct seq_file *m, const char *prefix, break; case BINDER_WORK_NODE: node = container_of(w, struct binder_node, work); - seq_printf(m, "%snode work %d: u%p c%p\n", - prefix, node->debug_id, node->ptr, node->cookie); + seq_printf(m, "%snode work %d: u%016llx c%016llx\n", + prefix, node->debug_id, + (u64)node->ptr, (u64)node->cookie); break; case BINDER_WORK_DEAD_BINDER: seq_printf(m, "%shas dead binder\n", prefix); @@ -3193,8 +3224,8 @@ static void print_binder_node(struct seq_file *m, struct binder_node *node) hlist_for_each_entry(ref, &node->refs, node_entry) count++; - seq_printf(m, " node %d: u%p c%p hs %d hw %d ls %d lw %d is %d iw %d", - node->debug_id, node->ptr, node->cookie, + seq_printf(m, " node %d: u%016llx c%016llx hs %d hw %d ls %d lw %d is %d iw %d", + node->debug_id, (u64)node->ptr, (u64)node->cookie, node->has_strong_ref, node->has_weak_ref, node->local_strong_refs, node->local_weak_refs, node->internal_strong_refs, count); @@ -3496,6 +3527,7 @@ static const struct file_operations binder_fops = { .owner = THIS_MODULE, .poll = binder_poll, .unlocked_ioctl = binder_ioctl, + .compat_ioctl = binder_ioctl, .mmap = binder_mmap, .open = binder_open, .flush = binder_flush, diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index d4101a671718..eb0834656dfe 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -20,6 +20,10 @@ #ifndef _LINUX_BINDER_H #define _LINUX_BINDER_H +#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT +#define BINDER_IPC_32BIT 1 +#endif + #include "uapi/binder.h" #endif /* _LINUX_BINDER_H */ diff --git a/drivers/staging/android/binder_trace.h b/drivers/staging/android/binder_trace.h index 82a567c2af67..7f20f3dc8369 100644 --- a/drivers/staging/android/binder_trace.h +++ b/drivers/staging/android/binder_trace.h @@ -152,7 +152,7 @@ TRACE_EVENT(binder_transaction_node_to_ref, TP_STRUCT__entry( __field(int, debug_id) __field(int, node_debug_id) - __field(void __user *, node_ptr) + __field(binder_uintptr_t, node_ptr) __field(int, ref_debug_id) __field(uint32_t, ref_desc) ), @@ -163,8 +163,9 @@ TRACE_EVENT(binder_transaction_node_to_ref, __entry->ref_debug_id = ref->debug_id; __entry->ref_desc = ref->desc; ), - TP_printk("transaction=%d node=%d src_ptr=0x%p ==> dest_ref=%d dest_desc=%d", - __entry->debug_id, __entry->node_debug_id, __entry->node_ptr, + TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d", + __entry->debug_id, __entry->node_debug_id, + (u64)__entry->node_ptr, __entry->ref_debug_id, __entry->ref_desc) ); @@ -177,7 +178,7 @@ TRACE_EVENT(binder_transaction_ref_to_node, __field(int, ref_debug_id) __field(uint32_t, ref_desc) __field(int, node_debug_id) - __field(void __user *, node_ptr) + __field(binder_uintptr_t, node_ptr) ), TP_fast_assign( __entry->debug_id = t->debug_id; @@ -186,9 +187,10 @@ TRACE_EVENT(binder_transaction_ref_to_node, __entry->node_debug_id = ref->node->debug_id; __entry->node_ptr = ref->node->ptr; ), - TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%p", + TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx", __entry->debug_id, __entry->node_debug_id, - __entry->ref_debug_id, __entry->ref_desc, __entry->node_ptr) + __entry->ref_debug_id, __entry->ref_desc, + (u64)__entry->node_ptr) ); TRACE_EVENT(binder_transaction_ref_to_ref, diff --git a/drivers/staging/android/uapi/binder.h b/drivers/staging/android/uapi/binder.h index 4071fcffa83c..904adb7600cf 100644 --- a/drivers/staging/android/uapi/binder.h +++ b/drivers/staging/android/uapi/binder.h @@ -39,6 +39,14 @@ enum { FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, }; +#ifdef BINDER_IPC_32BIT +typedef __u32 binder_size_t; +typedef __u32 binder_uintptr_t; +#else +typedef __u64 binder_size_t; +typedef __u64 binder_uintptr_t; +#endif + /* * This is the flattened representation of a Binder object for transfer * between processes. The 'offsets' supplied as part of a binder transaction @@ -53,12 +61,12 @@ struct flat_binder_object { /* 8 bytes of data. */ union { - void __user *binder; /* local object */ - __u32 handle; /* remote object */ + binder_uintptr_t binder; /* local object */ + __u32 handle; /* remote object */ }; /* extra data associated with local object */ - void __user *cookie; + binder_uintptr_t cookie; }; /* @@ -67,12 +75,12 @@ struct flat_binder_object { */ struct binder_write_read { - size_t write_size; /* bytes to write */ - size_t write_consumed; /* bytes consumed by driver */ - unsigned long write_buffer; - size_t read_size; /* bytes to read */ - size_t read_consumed; /* bytes consumed by driver */ - unsigned long read_buffer; + binder_size_t write_size; /* bytes to write */ + binder_size_t write_consumed; /* bytes consumed by driver */ + binder_uintptr_t write_buffer; + binder_size_t read_size; /* bytes to read */ + binder_size_t read_consumed; /* bytes consumed by driver */ + binder_uintptr_t read_buffer; }; /* Use with BINDER_VERSION, driver fills in fields. */ @@ -82,7 +90,11 @@ struct binder_version { }; /* This is the current protocol version. */ +#ifdef BINDER_IPC_32BIT #define BINDER_CURRENT_PROTOCOL_VERSION 7 +#else +#define BINDER_CURRENT_PROTOCOL_VERSION 8 +#endif #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) #define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) @@ -119,18 +131,20 @@ struct binder_transaction_data { * identifying the target and contents of the transaction. */ union { - __u32 handle; /* target descriptor of command transaction */ - void *ptr; /* target descriptor of return transaction */ + /* target descriptor of command transaction */ + __u32 handle; + /* target descriptor of return transaction */ + binder_uintptr_t ptr; } target; - void *cookie; /* target object cookie */ + binder_uintptr_t cookie; /* target object cookie */ __u32 code; /* transaction command */ /* General information about the transaction. */ __u32 flags; pid_t sender_pid; uid_t sender_euid; - size_t data_size; /* number of bytes of data */ - size_t offsets_size; /* number of bytes of offsets */ + binder_size_t data_size; /* number of bytes of data */ + binder_size_t offsets_size; /* number of bytes of offsets */ /* If this transaction is inline, the data immediately * follows here; otherwise, it ends with a pointer to @@ -139,22 +153,22 @@ struct binder_transaction_data { union { struct { /* transaction data */ - const void __user *buffer; + binder_uintptr_t buffer; /* offsets from buffer to flat_binder_object structs */ - const void __user *offsets; + binder_uintptr_t offsets; } ptr; __u8 buf[8]; } data; }; struct binder_ptr_cookie { - void *ptr; - void *cookie; + binder_uintptr_t ptr; + binder_uintptr_t cookie; }; struct binder_handle_cookie { __u32 handle; - void *cookie; + binder_uintptr_t cookie; } __attribute__((packed)); struct binder_pri_desc { @@ -164,8 +178,8 @@ struct binder_pri_desc { struct binder_pri_ptr_cookie { __s32 priority; - void *ptr; - void *cookie; + binder_uintptr_t ptr; + binder_uintptr_t cookie; }; enum binder_driver_return_protocol { @@ -240,11 +254,11 @@ enum binder_driver_return_protocol { * stop threadpool thread */ - BR_DEAD_BINDER = _IOR('r', 15, void *), + BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t), /* * void *: cookie */ - BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, void *), + BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), /* * void *: cookie */ @@ -270,7 +284,7 @@ enum binder_driver_command_protocol { * Else you have acquired a primary reference on the object. */ - BC_FREE_BUFFER = _IOW('c', 3, void *), + BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t), /* * void *: ptr to transaction data received on a read */ @@ -327,7 +341,7 @@ enum binder_driver_command_protocol { * void *: cookie */ - BC_DEAD_BINDER_DONE = _IOW('c', 16, void *), + BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), /* * void *: cookie */ From 1acec6a28347c3e57d9f882088f92caf0f4aec94 Mon Sep 17 00:00:00 2001 From: John Stultz Date: Fri, 21 Feb 2014 14:40:27 -0800 Subject: [PATCH 0432/1375] staging: binder: Improve Kconfig entry for ANDROID_BINDER_IPC_32BIT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a more clear explanation of the option in the prompt, and make the config depend on ANDROID_BINDER_IPC being selected. Also sets the default to y, which matches AOSP. Cc: Colin Cross Cc: Arve Hjønnevåg Cc: Serban Constantinescu Cc: Android Kernel Team Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 3559690273aa..1c779efc21aa 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -21,8 +21,9 @@ config ANDROID_BINDER_IPC between said processes. config ANDROID_BINDER_IPC_32BIT - bool "Use old 32-bit binder api" - depends on !64BIT + bool "Use old (Android 4.4 and earlier) 32-bit binder API" + depends on !64BIT && ANDROID_BINDER_IPC + default y ---help--- The Binder API has been changed to support both 32 and 64bit applications in a mixed environment. From 581b499a5141e9f145c82deac3c8dd39f0b1ec6f Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:11:57 -0500 Subject: [PATCH 0433/1375] staging: dgap: Remove CVS ID tags This patch removes all the original CVS tags because they are in my way Signed-off-by: Mark Hounschell Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_conf.h | 1 - drivers/staging/dgap/dgap_downld.h | 1 - drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_fep5.c | 1 - drivers/staging/dgap/dgap_parse.c | 1 - drivers/staging/dgap/dgap_pci.h | 1 - drivers/staging/dgap/dgap_sysfs.c | 1 - drivers/staging/dgap/dgap_trace.c | 1 - drivers/staging/dgap/dgap_trace.h | 1 - drivers/staging/dgap/dgap_tty.c | 1 - drivers/staging/dgap/digi.h | 1 - drivers/staging/dgap/downld.c | 1 - 12 files changed, 12 deletions(-) diff --git a/drivers/staging/dgap/dgap_conf.h b/drivers/staging/dgap/dgap_conf.h index 484ed726a4d6..92d22ecc6f07 100644 --- a/drivers/staging/dgap/dgap_conf.h +++ b/drivers/staging/dgap/dgap_conf.h @@ -20,7 +20,6 @@ * * dgap_conf.h - Header file for installations and parse files. * - * $Id: dgap_conf.h,v 1.1 2009/10/23 14:01:57 markh Exp $ * * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! */ diff --git a/drivers/staging/dgap/dgap_downld.h b/drivers/staging/dgap/dgap_downld.h index 910a45d3f1f7..7ea65315f701 100644 --- a/drivers/staging/dgap/dgap_downld.h +++ b/drivers/staging/dgap/dgap_downld.h @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: dgap_downld.h,v 1.1 2009/10/23 14:01:57 markh Exp $ * * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! * diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 11dd6dd51ddb..0f5fb1252172 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -27,7 +27,6 @@ * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * - * $Id: dgap_driver.c,v 1.3 2011/06/21 10:35:16 markh Exp $ */ diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index 51cda71400f8..fbc8a94653ac 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -17,7 +17,6 @@ * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * - * $Id: dgap_fep5.c,v 1.2 2011/06/21 10:35:40 markh Exp $ */ diff --git a/drivers/staging/dgap/dgap_parse.c b/drivers/staging/dgap/dgap_parse.c index 7bc5bc326bf8..65cd6127951b 100644 --- a/drivers/staging/dgap/dgap_parse.c +++ b/drivers/staging/dgap/dgap_parse.c @@ -32,7 +32,6 @@ * * dgap_parse.c - Parses the configuration information from the input file. * - * $Id: dgap_parse.c,v 1.1 2009/10/23 14:01:57 markh Exp $ * */ #include diff --git a/drivers/staging/dgap/dgap_pci.h b/drivers/staging/dgap/dgap_pci.h index 05ed374f08e1..bd498440a9b9 100644 --- a/drivers/staging/dgap/dgap_pci.h +++ b/drivers/staging/dgap/dgap_pci.h @@ -19,7 +19,6 @@ * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! */ -/* $Id: dgap_pci.h,v 1.1 2009/10/23 14:01:57 markh Exp $ */ #ifndef __DGAP_PCI_H #define __DGAP_PCI_H diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c index aa7e36f9d5d2..fef8ce11e65d 100644 --- a/drivers/staging/dgap/dgap_sysfs.c +++ b/drivers/staging/dgap/dgap_sysfs.c @@ -29,7 +29,6 @@ * * * - * $Id: dgap_sysfs.c,v 1.1 2009/10/23 14:01:57 markh Exp $ */ diff --git a/drivers/staging/dgap/dgap_trace.c b/drivers/staging/dgap/dgap_trace.c index a53db9e0a577..3ffadcb6d6c5 100644 --- a/drivers/staging/dgap/dgap_trace.c +++ b/drivers/staging/dgap/dgap_trace.c @@ -29,7 +29,6 @@ * */ -/* $Id: dgap_trace.c,v 1.1 2009/10/23 14:01:57 markh Exp $ */ #include #include /* For jiffies, task states */ diff --git a/drivers/staging/dgap/dgap_trace.h b/drivers/staging/dgap/dgap_trace.h index b21f46198e71..47ef0088c4b0 100644 --- a/drivers/staging/dgap/dgap_trace.h +++ b/drivers/staging/dgap/dgap_trace.h @@ -21,7 +21,6 @@ ***************************************************************************** * Header file for dgap_trace.c * - * $Id: dgap_trace.h,v 1.1 2009/10/23 14:01:57 markh Exp $ */ #ifndef __DGAP_TRACE_H diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 565319f883cb..9b3d3b5ed34e 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -35,7 +35,6 @@ * ************************************************************************ * - * $Id: dgap_tty.c,v 1.3 2011/06/23 12:11:31 markh Exp $ */ #include diff --git a/drivers/staging/dgap/digi.h b/drivers/staging/dgap/digi.h index fe8790396713..4f490a40416a 100644 --- a/drivers/staging/dgap/digi.h +++ b/drivers/staging/dgap/digi.h @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: digi.h,v 1.1 2009/10/23 14:01:57 markh Exp $ * * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! */ diff --git a/drivers/staging/dgap/downld.c b/drivers/staging/dgap/downld.c index 1f4aa2eca437..67200b593cb4 100644 --- a/drivers/staging/dgap/downld.c +++ b/drivers/staging/dgap/downld.c @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: downld.c,v 1.6 2009/01/14 14:10:54 markh Exp $ */ /* From be94358bb8f27b1a9e898ff81f4b028ee4fcc074 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:11:58 -0500 Subject: [PATCH 0434/1375] staging: dgap: Remove userland source code files This patch removes userland source code files downld.c and dgap_downld.h Signed-off-by: Mark Hounschell Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_downld.h | 68 --- drivers/staging/dgap/downld.c | 797 ----------------------------- 2 files changed, 865 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_downld.h delete mode 100644 drivers/staging/dgap/downld.c diff --git a/drivers/staging/dgap/dgap_downld.h b/drivers/staging/dgap/dgap_downld.h deleted file mode 100644 index 7ea65315f701..000000000000 --- a/drivers/staging/dgap/dgap_downld.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - * - */ - -/* -** downld.h -** - describes the interface between the user level download process -** and the concentrator download driver. -*/ - -#ifndef _DGAP_DOWNLD_H_ -#define _DGAP_DOWNLD_H_ - - -struct fepimg { - int type; /* board type */ - int len; /* length of image */ - char fepimage[1]; /* beginning of image */ -}; - -struct downldio { - unsigned int req_type; /* FEP or concentrator */ - unsigned int bdid; /* opaque board identifier */ - union { - struct downld_t dl; /* download structure */ - struct fepimg fi; /* fep/bios image structure */ - } image; -}; - -#define DIGI_DLREQ_GET (('d'<<8) | 220) -#define DIGI_DLREQ_SET (('d'<<8) | 221) - -#define DIGI_DL_NUKE (('d'<<8) | 222) /* Not really a dl request, but - dangerous enuff to not put in - digi.h */ -/* Packed bits of intarg for DIGI_DL_NUKE */ -#define DIGI_NUKE_RESET_ALL (1 << 31) -#define DIGI_NUKE_INHIBIT_POLLER (1 << 30) -#define DIGI_NUKE_BRD_NUMB 0x0f - - - -#define DLREQ_BIOS 0 -#define DLREQ_FEP 1 -#define DLREQ_CONC 2 -#define DLREQ_CONFIG 3 -#define DLREQ_DEVCREATE 4 - -#endif diff --git a/drivers/staging/dgap/downld.c b/drivers/staging/dgap/downld.c deleted file mode 100644 index 67200b593cb4..000000000000 --- a/drivers/staging/dgap/downld.c +++ /dev/null @@ -1,797 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* -** downld.c -** -** This is the daemon that sends the fep, bios, and concentrator images -** from user space to the driver. -** BUGS: -** If the file changes in the middle of the download, you probably -** will get what you deserve. -** -*/ - -#include -#include -#include -#include -#include -#include - -#include "dgap_types.h" -#include "digi.h" -#include "dgap_fep5.h" - -#include "dgap_downld.h" - -#include -#include -#include -#include - -char *pgm; -void myperror(); - -/* -** This structure is used to keep track of the different images available -** to give to the driver. It is arranged so that the things that are -** constants or that have defaults are first inthe strucutre to simplify -** the table of initializers. -*/ -struct image_info { - short type; /* bios, fep, conc */ - short family; /* boards this applies to */ - short subtype; /* subtype */ - int len; /* size of image */ - char *image; /* ioctl struct + image */ - char *name; - char *fname; /* filename of binary (i.e. "asfep.bin") */ - char *pathname; /* pathname to this binary ("/etc/dgap/xrfep.bin"); */ - time_t mtime; /* Last modification time */ -}; - -#define IBIOS 0 -#define IFEP 1 -#define ICONC 2 -#define ICONFIG 3 -#define IBAD 4 - -#define DEFAULT_LOC "/lib/firmware/dgap/" - -struct image_info *image_list; -int nimages, count; - -struct image_info images[] = { -{IBIOS, T_EPC, SUBTYPE, 0, NULL, "EPC/X", "fxbios.bin", DEFAULT_LOC "fxbios.bin", 0 }, -{IFEP, T_EPC, SUBTYPE, 0, NULL, "EPC/X", "fxfep.bin", DEFAULT_LOC "fxfep.bin", 0 }, -{ICONC, T_EPC, SUBTYPE, 0, NULL, "EPC/X", "fxcon.bin", DEFAULT_LOC "fxcon.bin", 0 }, - -{IBIOS, T_CX, SUBTYPE, 0, NULL, "C/X", "cxbios.bin", DEFAULT_LOC "cxbios.bin", 0 }, -{IFEP, T_CX, SUBTYPE, 0, NULL, "C/X", "cxhost.bin", DEFAULT_LOC "cxhost.bin", 0 }, - -{IBIOS, T_CX, T_PCIBUS, 0, NULL, "C/X PCI", "cxpbios.bin", DEFAULT_LOC "cxpbios.bin", 0 }, -{IFEP, T_CX, T_PCIBUS, 0, NULL, "C/X PCI", "cxpfep.bin", DEFAULT_LOC "cxpfep.bin", 0 }, - -{ICONC, T_CX, SUBTYPE, 0, NULL, "C/X", "cxcon.bin", DEFAULT_LOC "cxcon.bin", 0 }, -{ICONC, T_CX, SUBTYPE, 0, NULL, "C/X", "ibmcxcon.bin", DEFAULT_LOC "ibmcxcon.bin", 0 }, -{ICONC, T_CX, SUBTYPE, 0, NULL, "C/X", "ibmencon.bin", DEFAULT_LOC "ibmencon.bin", 0 }, - -{IBIOS, FAMILY, T_PCXR, 0, NULL, "PCXR", "xrbios.bin", DEFAULT_LOC "xrbios.bin", 0 }, -{IFEP, FAMILY, T_PCXR, 0, NULL, "PCXR", "xrfep.bin", DEFAULT_LOC "xrfep.bin", 0 }, - -{IBIOS, T_PCLITE, SUBTYPE, 0, NULL, "X/em", "sxbios.bin", DEFAULT_LOC "sxbios.bin", 0 }, -{IFEP, T_PCLITE, SUBTYPE, 0, NULL, "X/em", "sxfep.bin", DEFAULT_LOC "sxfep.bin", 0 }, - -{IBIOS, T_EPC, T_PCIBUS, 0, NULL, "PCI", "pcibios.bin", DEFAULT_LOC "pcibios.bin", 0 }, -{IFEP, T_EPC, T_PCIBUS, 0, NULL, "PCI", "pcifep.bin", DEFAULT_LOC "pcifep.bin", 0 }, -{ICONFIG, 0, 0, 0, NULL, NULL, "dgap.conf", "/etc/dgap.conf", 0 }, - -/* IBAD/NULL entry indicating end-of-table */ - -{IBAD, 0, 0, 0, NULL, NULL, NULL, NULL, 0 } - -} ; - -int errorprint = 1; -int nodldprint = 1; -int debugflag; -int fd; - -struct downld_t *ip; /* Image pointer in current image */ -struct downld_t *dp; /* conc. download */ - - -/* - * The same for either the FEP or the BIOS. - * Append the downldio header, issue the ioctl, then free - * the buffer. Not horribly CPU efficient, but quite RAM efficient. - */ - -void squirt(int req_type, int bdid, struct image_info *ii) -{ - struct downldio *dliop; - int size_buf; - int sfd; - struct stat sb; - - /* - * If this binary comes from a file, stat it to see how - * large it is. Yes, we intentionally do this each - * time for the binary may change between loads. - */ - - if (ii->pathname) { - sfd = open(ii->pathname, O_RDONLY); - - if (sfd < 0 ) { - myperror(ii->pathname); - goto squirt_end; - } - - if (fstat(sfd, &sb) == -1 ) { - myperror(ii->pathname); - goto squirt_end; - } - - ii->len = sb.st_size; - } - - size_buf = ii->len + sizeof(struct downldio); - - /* - * This buffer will be freed at the end of this function. It is - * not resilient and should be around only long enough for the d/l - * to happen. - */ - dliop = (struct downldio *) malloc(size_buf); - - if (dliop == NULL) { - fprintf(stderr,"%s: can't get %d bytes of memory; aborting\n", - pgm, size_buf); - exit (1); - } - - /* Now, stick the image in fepimage. This can come from either - * the compiled-in image or from the filesystem. - */ - if (ii->pathname) - read(sfd, dliop->image.fi.fepimage, ii->len); - else - memcpy(dliop ->image.fi.fepimage, ii->image, ii->len); - - dliop->req_type = req_type; - dliop->bdid = bdid; - - dliop->image.fi.len = ii->len; - - if (debugflag) - printf("sending %d bytes of %s %s from %s\n", - ii->len, - (ii->type == IFEP) ? "FEP" : (ii->type == IBIOS) ? "BIOS" : "CONFIG", - ii->name ? ii->name : "", - (ii->pathname) ? ii->pathname : "internal image" ); - - if (ioctl(fd, DIGI_DLREQ_SET, (char *) dliop) == -1) { - if(errorprint) { - fprintf(stderr, - "%s: warning - download ioctl failed\n",pgm); - errorprint = 0; - } - sleep(2); - } - -squirt_end: - - if (ii->pathname) { - close(sfd); - } - free(dliop); -} - - -/* - * See if we need to reload the download image in core - * - */ -void consider_file_rescan(struct image_info *ii) -{ - int sfd; - int len; - struct stat sb; - - /* This operation only makes sense when we're working from a file */ - - if (ii->pathname) { - - sfd = open (ii->pathname, O_RDONLY) ; - if (sfd < 0 ) { - myperror(ii->pathname); - exit(1) ; - } - - if( fstat(sfd,&sb) == -1 ) { - myperror(ii->pathname); - exit(1); - } - - /* If the file hasn't changed since we last did this, - * and we have not done a free() on the image, bail - */ - if (ii->image && (sb.st_mtime == ii->mtime)) - goto end_rescan; - - ii->len = len = sb.st_size; - - /* Record the timestamp of the file */ - ii->mtime = sb.st_mtime; - - /* image should be NULL unless there is an image malloced - * in already. Before we malloc again, make sure we don't - * have a memory leak. - */ - if ( ii->image ) { - free( ii->image ); - /* ii->image = NULL; */ /* not necessary */ - } - - /* This image will be kept only long enough for the - * download to happen. After sending the last block, - * it will be freed - */ - ii->image = malloc(len) ; - - if (ii->image == NULL) { - fprintf(stderr, - "%s: can't get %d bytes of memory; aborting\n", - pgm, len); - exit (1); - } - - if (read(sfd, ii->image, len) < len) { - fprintf(stderr,"%s: read error on %s; aborting\n", - pgm, ii->pathname); - exit (1); - } - -end_rescan: - close(sfd); - - } -} - -/* - * Scan for images to match the driver requests - */ - -struct image_info * find_conc_image() -{ - int x; - struct image_info *i = NULL; - - for ( x = 0; x < nimages; x++ ) { - i=&image_list[x]; - - if(i->type != ICONC) - continue; - - consider_file_rescan(i) ; - - ip = (struct downld_t *) image_list[x].image; - if (ip == NULL) continue; - - /* - * When I removed Clusterport, I kept only the code that I - * was SURE wasn't ClusterPort. We may not need the next two - * lines of code. - */ - if ((dp->dl_type != 'P' ) && ( ip->dl_srev == dp->dl_srev )) - return i; - } - return NULL; -} - - -int main(int argc, char **argv) -{ - struct downldio dlio; - int offset, bsize; - int x; - char *down, *image, *fname; - struct image_info *ii; - - pgm = argv[0]; - dp = &dlio.image.dl; /* conc. download */ - - while((argc > 2) && !strcmp(argv[1],"-d")) { - debugflag++ ; - argc-- ; - argv++ ; - } - - if(argc < 2) { - fprintf(stderr, - "usage: %s download-device [image-file] ...\n", - pgm); - exit(1); - } - - - - /* - * Daemonize, unless debugging is turned on. - */ - if (debugflag == 0) { - switch (fork()) - { - case 0: - break; - - case -1: - return 1; - - default: - return 0; - } - - setsid(); - - /* - * The child no longer needs "stdin", "stdout", or "stderr", - * and should not block processes waiting for them to close. - */ - fclose(stdin); - fclose(stdout); - fclose(stderr); - - } - - while (1) { - if( (fd = open(argv[1], O_RDWR)) == -1 ) { - sleep(1); - } - else - break; - } - - /* - ** create a list of images to search through when trying to match - ** requests from the driver. Put images from the command line in - ** the list before built in images so that the command line images - ** can override the built in ones. - */ - - /* allocate space for the list */ - - nimages = argc - 2; - - /* count the number of default list entries */ - - for (count = 0; images[count].type != IBAD; ++count) ; - - nimages += count; - - /* Really should just remove the variable "image_list".... robertl */ - image_list = images; - - /* get the images from the command line */ - for(x = 2; x < argc; x++) { - int xx; - - /* - * strip off any leading path information for - * determining file type - */ - if( (fname = strrchr(argv[x],'/')) == NULL) - fname = argv[x]; - else - fname++; /* skip the slash */ - - for (xx = 0; xx < count; xx++) { - if (strcmp(fname, images[xx].fname) == 0 ) { - images[xx].pathname = argv[x]; - - /* image should be NULL until */ - /* space is malloced */ - images[xx].image = NULL; - } - } - } - - sleep(3); - - /* - ** Endless loop: get a request from the fep, and service that request. - */ - for(;;) { - /* get the request */ - if (debugflag) - printf("b4 get ioctl..."); - - if (ioctl(fd,DIGI_DLREQ_GET, &dlio) == -1 ) { - if (errorprint) { - fprintf(stderr, - "%s: warning - download ioctl failed\n", - pgm); - errorprint = 0; - } - sleep(2); - } else { - if (debugflag) - printf("dlio.req_type is %d bd %d\n", - dlio.req_type,dlio.bdid); - - switch(dlio.req_type) { - case DLREQ_BIOS: - /* - ** find the bios image for this type - */ - for ( x = 0; x < nimages; x++ ) { - if(image_list[x].type != IBIOS) - continue; - - if ((dlio.image.fi.type & FAMILY) == - image_list[x].family) { - - if ( image_list[x].family == T_CX ) { - if ((dlio.image.fi.type & BUSTYPE) - == T_PCIBUS ) { - if ( image_list[x].subtype - == T_PCIBUS ) - break; - } - else { - break; - } - } - else if ( image_list[x].family == T_EPC ) { - /* If subtype of image is T_PCIBUS, it is */ - /* a PCI EPC image, so the board must */ - /* have bus type T_PCIBUS to match */ - if ((dlio.image.fi.type & BUSTYPE) - == T_PCIBUS ) { - if ( image_list[x].subtype - == T_PCIBUS ) - break; - } - else { - /* NON PCI EPC doesn't use PCI image */ - if ( image_list[x].subtype - != T_PCIBUS ) - break; - } - } - else - break; - } - else if ((dlio.image.fi.type & SUBTYPE) == image_list[x].subtype) { - /* PCXR board will break out of the loop here */ - if ( image_list[x].subtype == T_PCXR ) { - break; - } - } - } - - if ( x >= nimages) { - /* - ** no valid images exist - */ - if(nodldprint) { - fprintf(stderr, - "%s: cannot find correct BIOS image\n", - pgm); - nodldprint = 0; - } - dlio.image.fi.type = -1; - if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1) { - if (errorprint) { - fprintf(stderr, - "%s: warning - download ioctl failed\n", - pgm); - errorprint = 0; - } - sleep(2); - } - break; - } - squirt(dlio.req_type, dlio.bdid, &image_list[x]); - break ; - - case DLREQ_FEP: - /* - ** find the fep image for this type - */ - for ( x = 0; x < nimages; x++ ) { - if(image_list[x].type != IFEP) - continue; - if( (dlio.image.fi.type & FAMILY) == - image_list[x].family ) { - if ( image_list[x].family == T_CX ) { - /* C/X PCI board */ - if ((dlio.image.fi.type & BUSTYPE) - == T_PCIBUS ) { - if ( image_list[x].subtype - == T_PCIBUS ) - break; - } - else { - /* Regular CX */ - break; - } - } - else if ( image_list[x].family == T_EPC ) { - /* If subtype of image is T_PCIBUS, it is */ - /* a PCI EPC image, so the board must */ - /* have bus type T_PCIBUS to match */ - if ((dlio.image.fi.type & BUSTYPE) - == T_PCIBUS ) { - if ( image_list[x].subtype - == T_PCIBUS ) - break; - } - else { - /* NON PCI EPC doesn't use PCI image */ - if ( image_list[x].subtype - != T_PCIBUS ) - break; - } - } - else - break; - } - else if ((dlio.image.fi.type & SUBTYPE) == image_list[x].subtype) { - /* PCXR board will break out of the loop here */ - if ( image_list[x].subtype == T_PCXR ) { - break; - } - } - } - - if ( x >= nimages) { - /* - ** no valid images exist - */ - if(nodldprint) { - fprintf(stderr, - "%s: cannot find correct FEP image\n", - pgm); - nodldprint = 0; - } - dlio.image.fi.type=-1; - if( ioctl(fd,DIGI_DLREQ_SET,&dlio) == -1 ) { - if(errorprint) { - fprintf(stderr, - "%s: warning - download ioctl failed\n", - pgm); - errorprint=0; - } - sleep(2); - } - break; - } - squirt(dlio.req_type, dlio.bdid, &image_list[x]); - break; - - case DLREQ_DEVCREATE: - { - char string[1024]; -#if 0 - sprintf(string, "%s /proc/dgap/%d/mknod", DEFSHELL, dlio.bdid); -#endif - sprintf(string, "%s /usr/sbin/dgap_updatedevs %d", DEFSHELL, dlio.bdid); - system(string); - - if (debugflag) - printf("Created Devices.\n"); - if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1 ) { - if(errorprint) { - fprintf(stderr, "%s: warning - DEVCREATE ioctl failed\n",pgm); - errorprint = 0; - } - sleep(2); - } - if (debugflag) - printf("After ioctl set - Created Device.\n"); - } - - break; - - case DLREQ_CONFIG: - for ( x = 0; x < nimages; x++ ) { - if(image_list[x].type != ICONFIG) - continue; - else - break; - } - - if ( x >= nimages) { - /* - ** no valid images exist - */ - if(nodldprint) { - fprintf(stderr, - "%s: cannot find correct CONFIG image\n", - pgm); - nodldprint = 0; - } - dlio.image.fi.type=-1; - if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1 ) { - if(errorprint) { - fprintf(stderr, - "%s: warning - download ioctl failed\n", - pgm); - errorprint=0; - } - sleep(2); - } - break; - } - - squirt(dlio.req_type, dlio.bdid, &image_list[x]); - break; - - case DLREQ_CONC: - /* - ** find the image needed for this download - */ - if ( dp->dl_seq == 0 ) { - /* - ** find image for hardware rev range - */ - for ( x = 0; x < nimages; x++ ) { - ii=&image_list[x]; - - if(image_list[x].type != ICONC) - continue; - - consider_file_rescan(ii) ; - - ip = (struct downld_t *) image_list[x].image; - if (ip == NULL) continue; - - /* - * When I removed Clusterport, I kept only the - * code that I was SURE wasn't ClusterPort. - * We may not need the next four lines of code. - */ - - if ((dp->dl_type != 'P' ) && - (ip->dl_lrev <= dp->dl_lrev ) && - ( dp->dl_lrev <= ip->dl_hrev)) - break; - } - - if ( x >= nimages ) { - /* - ** No valid images exist - */ - if(nodldprint) { - fprintf(stderr, - "%s: cannot find correct download image %d\n", - pgm, dp->dl_lrev); - nodldprint=0; - } - continue; - } - - } else { - /* - ** find image version required - */ - if ((ii = find_conc_image()) == NULL ) { - /* - ** No valid images exist - */ - fprintf(stderr, - "%s: can't find rest of download image??\n", - pgm); - continue; - } - } - - /* - ** download block of image - */ - - offset = 1024 * dp->dl_seq; - - /* - ** test if block requested within image - */ - if ( offset < ii->len ) { - - /* - ** if it is, determine block size, set segment, - ** set size, set pointers, and copy block - */ - if (( bsize = ii->len - offset ) > 1024 ) - bsize = 1024; - - /* - ** copy image version info to download area - */ - dp->dl_srev = ip->dl_srev; - dp->dl_lrev = ip->dl_lrev; - dp->dl_hrev = ip->dl_hrev; - - dp->dl_seg = (64 * dp->dl_seq) + ip->dl_seg; - dp->dl_size = bsize; - - down = (char *)&dp->dl_data[0]; - image = (char *)((char *)ip + offset); - - memcpy(down, image, bsize); - } - else { - /* - ** Image has been downloaded, set segment and - ** size to indicate no more blocks - */ - dp->dl_seg = ip->dl_seg; - dp->dl_size = 0; - - /* Now, we can release the concentrator */ - /* image from memory if we're running */ - /* from filesystem images */ - - if (ii->pathname) - if (ii->image) { - free(ii->image); - ii->image = NULL; - } - } - - if (debugflag) - printf( - "sending conc dl section %d to %s from %s\n", - dp->dl_seq, ii->name, - ii->pathname ? ii->pathname : "Internal Image"); - - if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1 ) { - if (errorprint) { - fprintf(stderr, - "%s: warning - download ioctl failed\n", - pgm); - errorprint=0; - } - sleep(2); - } - break; - } /* switch */ - } - if (debugflag > 1) { - printf("pausing: "); fflush(stdout); - fflush(stdin); - while(getchar() != '\n'); - printf("continuing\n"); - } - } -} - -/* -** myperror() -** -** Same as normal perror(), but places the program name at the beginning -** of the message. -*/ -void myperror(char *s) -{ - fprintf(stderr,"%s: %s: %s.\n",pgm, s, strerror(errno)); -} From a6792a3e6e39ac300069ecbf4f4be1c9dc8a71ab Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:11:59 -0500 Subject: [PATCH 0435/1375] staging: dgap: Merge dgap_tty.c into dgap_driver.c There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 2 +- drivers/staging/dgap/dgap_driver.c | 3495 +++++++++++++++++++++++++++ drivers/staging/dgap/dgap_tty.c | 3555 ---------------------------- 3 files changed, 3496 insertions(+), 3556 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_tty.c diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index 3abe8d2bb748..b80cad5f95c5 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -3,5 +3,5 @@ obj-$(CONFIG_DGAP) += dgap.o dgap-objs := dgap_driver.o dgap_fep5.o \ dgap_parse.o dgap_trace.o \ - dgap_tty.o dgap_sysfs.o + dgap_sysfs.o diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 0f5fb1252172..b49f6988a7f6 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -38,6 +38,13 @@ #include /* For copy_from_user/copy_to_user */ #include +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include +#include +#include /* For read[bwl]/write[bwl] */ + #include "dgap_driver.h" #include "dgap_pci.h" #include "dgap_fep5.h" @@ -46,6 +53,11 @@ #include "dgap_parse.h" #include "dgap_trace.h" #include "dgap_sysfs.h" +#include "dgap_types.h" + +#define init_MUTEX(sem) sema_init(sem, 1) +#define DECLARE_MUTEX(name) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) MODULE_LICENSE("GPL"); MODULE_AUTHOR("Digi International, http://www.digi.com"); @@ -82,6 +94,38 @@ static void dgap_mbuf(struct board_t *brd, const char *fmt, ...); static int dgap_do_remap(struct board_t *brd); static irqreturn_t dgap_intr(int irq, void *voidbrd); +/* Our function prototypes */ +static int dgap_tty_open(struct tty_struct *tty, struct file *file); +static void dgap_tty_close(struct tty_struct *tty, struct file *file); +static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); +static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); +static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); +static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo); +static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info); +static int dgap_tty_write_room(struct tty_struct* tty); +static int dgap_tty_chars_in_buffer(struct tty_struct* tty); +static void dgap_tty_start(struct tty_struct *tty); +static void dgap_tty_stop(struct tty_struct *tty); +static void dgap_tty_throttle(struct tty_struct *tty); +static void dgap_tty_unthrottle(struct tty_struct *tty); +static void dgap_tty_flush_chars(struct tty_struct *tty); +static void dgap_tty_flush_buffer(struct tty_struct *tty); +static void dgap_tty_hangup(struct tty_struct *tty); +static int dgap_wait_for_drain(struct tty_struct *tty); +static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value); +static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value); +static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info); +static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo); +static int dgap_tty_tiocmget(struct tty_struct *tty); +static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); +static int dgap_tty_send_break(struct tty_struct *tty, int msec); +static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout); +static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); +static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); +static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c); +static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); + /* Driver load/unload functions */ int dgap_init_module(void); void dgap_cleanup_module(void); @@ -121,6 +165,10 @@ static uint dgap_driver_start = FALSE; static struct class * dgap_class; +static struct board_t *dgap_BoardsByMajor[256]; +static uchar *dgap_TmpWriteBuf = NULL; +static DECLARE_MUTEX(dgap_TmpWriteSem); + /* * Poller stuff */ @@ -220,6 +268,62 @@ char *dgap_driver_state_text[] = { "Driver Ready." }; +/* + * Default transparent print information. + */ +static struct digi_t dgap_digi_init = { + .digi_flags = DIGI_COOK, /* Flags */ + .digi_maxcps = 100, /* Max CPS */ + .digi_maxchar = 50, /* Max chars in print queue */ + .digi_bufsize = 100, /* Printer buffer size */ + .digi_onlen = 4, /* size of printer on string */ + .digi_offlen = 4, /* size of printer off string */ + .digi_onstr = "\033[5i", /* ANSI printer on string ] */ + .digi_offstr = "\033[4i", /* ANSI printer off string ] */ + .digi_term = "ansi" /* default terminal type */ +}; + + +/* + * Define a local default termios struct. All ports will be created + * with this termios initially. + * + * This defines a raw port at 9600 baud, 8 data bits, no parity, + * 1 stop bit. + */ + +static struct ktermios DgapDefaultTermios = +{ + .c_iflag = (DEFAULT_IFLAGS), /* iflags */ + .c_oflag = (DEFAULT_OFLAGS), /* oflags */ + .c_cflag = (DEFAULT_CFLAGS), /* cflags */ + .c_lflag = (DEFAULT_LFLAGS), /* lflags */ + .c_cc = INIT_C_CC, + .c_line = 0, +}; + +static const struct tty_operations dgap_tty_ops = { + .open = dgap_tty_open, + .close = dgap_tty_close, + .write = dgap_tty_write, + .write_room = dgap_tty_write_room, + .flush_buffer = dgap_tty_flush_buffer, + .chars_in_buffer = dgap_tty_chars_in_buffer, + .flush_chars = dgap_tty_flush_chars, + .ioctl = dgap_tty_ioctl, + .set_termios = dgap_tty_set_termios, + .stop = dgap_tty_stop, + .start = dgap_tty_start, + .throttle = dgap_tty_throttle, + .unthrottle = dgap_tty_unthrottle, + .hangup = dgap_tty_hangup, + .put_char = dgap_tty_put_char, + .tiocmget = dgap_tty_tiocmget, + .tiocmset = dgap_tty_tiocmset, + .break_ctl = dgap_tty_send_break, + .wait_until_sent = dgap_tty_wait_until_sent, + .send_xchar = dgap_tty_send_xchar +}; /************************************************************************ @@ -1027,3 +1131,3394 @@ char *dgap_ioctl_name(int cmd) default: return("unknown"); } } + +/************************************************************************ + * + * TTY Initialization/Cleanup Functions + * + ************************************************************************/ + +/* + * dgap_tty_preinit() + * + * Initialize any global tty related data before we download any boards. + */ +int dgap_tty_preinit(void) +{ + unsigned long flags; + + DGAP_LOCK(dgap_global_lock, flags); + + /* + * Allocate a buffer for doing the copy from user space to + * kernel space in dgap_input(). We only use one buffer and + * control access to it with a semaphore. If we are paging, we + * are already in trouble so one buffer won't hurt much anyway. + */ + dgap_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_ATOMIC); + + if (!dgap_TmpWriteBuf) { + DGAP_UNLOCK(dgap_global_lock, flags); + DPR_INIT(("unable to allocate tmp write buf")); + return (-ENOMEM); + } + + DGAP_UNLOCK(dgap_global_lock, flags); + return(0); +} + + +/* + * dgap_tty_register() + * + * Init the tty subsystem for this board. + */ +int dgap_tty_register(struct board_t *brd) +{ + int rc = 0; + + DPR_INIT(("tty_register start")); + + brd->SerialDriver = alloc_tty_driver(MAXPORTS); + + snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgap_%d_", brd->boardnum); + brd->SerialDriver->name = brd->SerialName; + brd->SerialDriver->name_base = 0; + brd->SerialDriver->major = 0; + brd->SerialDriver->minor_start = 0; + brd->SerialDriver->type = TTY_DRIVER_TYPE_SERIAL; + brd->SerialDriver->subtype = SERIAL_TYPE_NORMAL; + brd->SerialDriver->init_termios = DgapDefaultTermios; + brd->SerialDriver->driver_name = DRVSTR; + brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + + /* The kernel wants space to store pointers to tty_structs */ + brd->SerialDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->SerialDriver->ttys) + return(-ENOMEM); + + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(brd->SerialDriver, &dgap_tty_ops); + + /* + * If we're doing transparent print, we have to do all of the above + * again, separately so we don't get the LD confused about what major + * we are when we get into the dgap_tty_open() routine. + */ + brd->PrintDriver = alloc_tty_driver(MAXPORTS); + + snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgap_%d_", brd->boardnum); + brd->PrintDriver->name = brd->PrintName; + brd->PrintDriver->name_base = 0; + brd->PrintDriver->major = 0; + brd->PrintDriver->minor_start = 0; + brd->PrintDriver->type = TTY_DRIVER_TYPE_SERIAL; + brd->PrintDriver->subtype = SERIAL_TYPE_NORMAL; + brd->PrintDriver->init_termios = DgapDefaultTermios; + brd->PrintDriver->driver_name = DRVSTR; + brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + + /* The kernel wants space to store pointers to tty_structs */ + brd->PrintDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->PrintDriver->ttys) + return(-ENOMEM); + + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(brd->PrintDriver, &dgap_tty_ops); + + if (!brd->dgap_Major_Serial_Registered) { + /* Register tty devices */ + rc = tty_register_driver(brd->SerialDriver); + if (rc < 0) { + APR(("Can't register tty device (%d)\n", rc)); + return(rc); + } + brd->dgap_Major_Serial_Registered = TRUE; + dgap_BoardsByMajor[brd->SerialDriver->major] = brd; + brd->dgap_Serial_Major = brd->SerialDriver->major; + } + + if (!brd->dgap_Major_TransparentPrint_Registered) { + /* Register Transparent Print devices */ + rc = tty_register_driver(brd->PrintDriver); + if (rc < 0) { + APR(("Can't register Transparent Print device (%d)\n", rc)); + return(rc); + } + brd->dgap_Major_TransparentPrint_Registered = TRUE; + dgap_BoardsByMajor[brd->PrintDriver->major] = brd; + brd->dgap_TransparentPrint_Major = brd->PrintDriver->major; + } + + DPR_INIT(("DGAP REGISTER TTY: MAJORS: %d %d\n", brd->SerialDriver->major, + brd->PrintDriver->major)); + + return (rc); +} + + +/* + * dgap_tty_init() + * + * Init the tty subsystem. Called once per board after board has been + * downloaded and init'ed. + */ +int dgap_tty_init(struct board_t *brd) +{ + int i; + int tlw; + uint true_count = 0; + uchar *vaddr; + uchar modem = 0; + struct channel_t *ch; + struct bs_t *bs; + struct cm_t *cm; + + if (!brd) + return (-ENXIO); + + DPR_INIT(("dgap_tty_init start\n")); + + /* + * Initialize board structure elements. + */ + + vaddr = brd->re_map_membase; + true_count = readw((vaddr + NCHAN)); + + brd->nasync = dgap_config_get_number_of_ports(brd); + + if (!brd->nasync) { + brd->nasync = brd->maxports; + } + + if (brd->nasync > brd->maxports) { + brd->nasync = brd->maxports; + } + + if (true_count != brd->nasync) { + if ((brd->type == PPCM) && (true_count == 64)) { + APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n", + brd->name, brd->nasync, true_count)); + } + else if ((brd->type == PPCM) && (true_count == 0)) { + APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n", + brd->name, brd->nasync, true_count)); + } + else { + APR(("***WARNING**** %s configured for %d ports, has %d ports.\n", + brd->name, brd->nasync, true_count)); + } + + brd->nasync = true_count; + + /* If no ports, don't bother going any further */ + if (!brd->nasync) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return(-ENXIO); + } + } + + /* + * 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]) { + brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_ATOMIC); + if (!brd->channels[i]) { + DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", + __FILE__, __LINE__)); + } + } + } + + ch = brd->channels[0]; + vaddr = brd->re_map_membase; + + bs = (struct bs_t *) ((ulong) vaddr + CHANBUF); + cm = (struct cm_t *) ((ulong) vaddr + CMDBUF); + + brd->bd_bs = bs; + + /* Set up channel variables */ + for (i = 0; i < brd->nasync; i++, ch = brd->channels[i], bs++) { + + if (!brd->channels[i]) + continue; + + DGAP_SPINLOCK_INIT(ch->ch_lock); + + /* Store all our magic numbers */ + ch->magic = DGAP_CHANNEL_MAGIC; + ch->ch_tun.magic = DGAP_UNIT_MAGIC; + ch->ch_tun.un_type = DGAP_SERIAL; + ch->ch_tun.un_ch = ch; + ch->ch_tun.un_dev = i; + + ch->ch_pun.magic = DGAP_UNIT_MAGIC; + ch->ch_pun.un_type = DGAP_PRINT; + ch->ch_pun.un_ch = ch; + ch->ch_pun.un_dev = i; + + ch->ch_vaddr = vaddr; + ch->ch_bs = bs; + ch->ch_cm = cm; + ch->ch_bd = brd; + ch->ch_portnum = i; + ch->ch_digi = dgap_digi_init; + + /* + * Set up digi dsr and dcd bits based on altpin flag. + */ + if (dgap_config_get_altpin(brd)) { + ch->ch_dsr = DM_CD; + ch->ch_cd = DM_DSR; + ch->ch_digi.digi_flags |= DIGI_ALTPIN; + } + else { + ch->ch_cd = DM_CD; + ch->ch_dsr = DM_DSR; + } + + ch->ch_taddr = vaddr + ((ch->ch_bs->tx_seg) << 4); + ch->ch_raddr = vaddr + ((ch->ch_bs->rx_seg) << 4); + ch->ch_tx_win = 0; + ch->ch_rx_win = 0; + ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1; + ch->ch_rsize = readw(&(ch->ch_bs->rx_max)) + 1; + ch->ch_tstart = 0; + ch->ch_rstart = 0; + + /* .25 second delay */ + ch->ch_close_delay = 250; + + /* + * Set queue water marks, interrupt mask, + * and general tty parameters. + */ + ch->ch_tlw = tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) : ch->ch_tsize / 2; + + dgap_cmdw(ch, STLOW, tlw, 0); + + dgap_cmdw(ch, SRLOW, ch->ch_rsize / 2, 0); + + dgap_cmdw(ch, SRHIGH, 7 * ch->ch_rsize / 8, 0); + + ch->ch_mistat = readb(&(ch->ch_bs->m_stat)); + + init_waitqueue_head(&ch->ch_flags_wait); + init_waitqueue_head(&ch->ch_tun.un_flags_wait); + init_waitqueue_head(&ch->ch_pun.un_flags_wait); + init_waitqueue_head(&ch->ch_sniff_wait); + + /* Turn on all modem interrupts for now */ + modem = (DM_CD | DM_DSR | DM_CTS | DM_RI); + writeb(modem, &(ch->ch_bs->m_int)); + + /* + * Set edelay to 0 if interrupts are turned on, + * otherwise set edelay to the usual 100. + */ + if (brd->intr_used) + writew(0, &(ch->ch_bs->edelay)); + else + writew(100, &(ch->ch_bs->edelay)); + + writeb(1, &(ch->ch_bs->idata)); + } + + + DPR_INIT(("dgap_tty_init finish\n")); + + return (0); +} + + +/* + * dgap_tty_post_uninit() + * + * UnInitialize any global tty related data. + */ +void dgap_tty_post_uninit(void) +{ + kfree(dgap_TmpWriteBuf); + dgap_TmpWriteBuf = NULL; +} + + +/* + * dgap_tty_uninit() + * + * Uninitialize the TTY portion of this driver. Free all memory and + * resources. + */ +void dgap_tty_uninit(struct board_t *brd) +{ + int i = 0; + + if (brd->dgap_Major_Serial_Registered) { + dgap_BoardsByMajor[brd->SerialDriver->major] = NULL; + brd->dgap_Serial_Major = 0; + for (i = 0; i < brd->nasync; i++) { + dgap_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); + tty_unregister_device(brd->SerialDriver, i); + } + tty_unregister_driver(brd->SerialDriver); + kfree(brd->SerialDriver->ttys); + brd->SerialDriver->ttys = NULL; + put_tty_driver(brd->SerialDriver); + brd->dgap_Major_Serial_Registered = FALSE; + } + + if (brd->dgap_Major_TransparentPrint_Registered) { + dgap_BoardsByMajor[brd->PrintDriver->major] = NULL; + brd->dgap_TransparentPrint_Major = 0; + for (i = 0; i < brd->nasync; i++) { + dgap_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); + tty_unregister_device(brd->PrintDriver, i); + } + tty_unregister_driver(brd->PrintDriver); + kfree(brd->PrintDriver->ttys); + brd->PrintDriver->ttys = NULL; + put_tty_driver(brd->PrintDriver); + brd->dgap_Major_TransparentPrint_Registered = FALSE; + } +} + + +#define TMPBUFLEN (1024) + +/* + * dgap_sniff - Dump data out to the "sniff" buffer if the + * proc sniff file is opened... + */ +static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int len) +{ + struct timeval tv; + int n; + int r; + int nbuf; + int i; + int tmpbuflen; + char tmpbuf[TMPBUFLEN]; + char *p = tmpbuf; + int too_much_data; + + /* Leave if sniff not open */ + if (!(ch->ch_sniff_flags & SNIFF_OPEN)) + return; + + do_gettimeofday(&tv); + + /* Create our header for data dump */ + p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text); + tmpbuflen = p - tmpbuf; + + do { + too_much_data = 0; + + for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) { + p += sprintf(p, "%02x ", *buf); + buf++; + tmpbuflen = p - tmpbuf; + } + + if (tmpbuflen < (TMPBUFLEN - 4)) { + if (i > 0) + p += sprintf(p - 1, "%s\n", ">"); + else + p += sprintf(p, "%s\n", ">"); + } else { + too_much_data = 1; + len -= i; + } + + nbuf = strlen(tmpbuf); + p = tmpbuf; + + /* + * Loop while data remains. + */ + while (nbuf > 0 && ch->ch_sniff_buf) { + /* + * Determine the amount of available space left in the + * buffer. If there's none, wait until some appears. + */ + n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & SNIFF_MASK; + + /* + * If there is no space left to write to in our sniff buffer, + * we have no choice but to drop the data. + * We *cannot* sleep here waiting for space, because this + * function was probably called by the interrupt/timer routines! + */ + if (n == 0) { + return; + } + + /* + * Copy as much data as will fit. + */ + + if (n > nbuf) + n = nbuf; + + r = SNIFF_MAX - ch->ch_sniff_in; + + if (r <= n) { + memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, r); + + n -= r; + ch->ch_sniff_in = 0; + p += r; + nbuf -= r; + } + + memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n); + + ch->ch_sniff_in += n; + p += n; + nbuf -= n; + + /* + * Wakeup any thread waiting for data + */ + if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) { + ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA; + wake_up_interruptible(&ch->ch_sniff_wait); + } + } + + /* + * If the user sent us too much data to push into our tmpbuf, + * we need to keep looping around on all the data. + */ + if (too_much_data) { + p = tmpbuf; + tmpbuflen = 0; + } + + } while (too_much_data); +} + + +/*======================================================================= + * + * dgap_input - Process received data. + * + * ch - Pointer to channel structure. + * + *=======================================================================*/ + +void dgap_input(struct channel_t *ch) +{ + struct board_t *bd; + struct bs_t *bs; + struct tty_struct *tp; + struct tty_ldisc *ld; + uint rmask; + uint head; + uint tail; + int data_len; + ulong lock_flags; + ulong lock_flags2; + int flip_len; + int len = 0; + int n = 0; + uchar *buf; + uchar tmpchar; + int s = 0; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + tp = ch->ch_tun.un_tty; + + bs = ch->ch_bs; + if (!bs) { + return; + } + + bd = ch->ch_bd; + if(!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_READ(("dgap_input start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* + * Figure the number of characters in the buffer. + * Exit immediately if none. + */ + + rmask = ch->ch_rsize - 1; + + head = readw(&(bs->rx_head)); + head &= rmask; + tail = readw(&(bs->rx_tail)); + tail &= rmask; + + data_len = (head - tail) & rmask; + + if (data_len == 0) { + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_READ(("No data on port %d\n", ch->ch_portnum)); + return; + } + + /* + * If the device is not open, or CREAD is off, flush + * input data and return immediately. + */ + if ((bd->state != BOARD_READY) || !tp || (tp->magic != TTY_MAGIC) || + !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios.c_cflag & CREAD) || + (ch->ch_tun.un_flags & UN_CLOSING)) { + + DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); + DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n", + tp, tp ? tp->magic : 0, TTY_MAGIC, ch->ch_tun.un_flags)); + writew(head, &(bs->rx_tail)); + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + + /* + * If we are throttled, simply don't read any data. + */ + if (ch->ch_flags & CH_RXBLOCK) { + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_READ(("Port %d throttled, not reading any data. head: %x tail: %x\n", + ch->ch_portnum, head, tail)); + return; + } + + /* + * Ignore oruns. + */ + tmpchar = readb(&(bs->orun)); + if (tmpchar) { + ch->ch_err_overrun++; + writeb(0, &(bs->orun)); + } + + DPR_READ(("dgap_input start 2\n")); + + /* Decide how much data we can send into the tty layer */ + flip_len = TTY_FLIPBUF_SIZE; + + /* Chop down the length, if needed */ + len = min(data_len, flip_len); + len = min(len, (N_TTY_BUF_SIZE - 1)); + + 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 + * have any space to put the data right now. + */ + if (!ld) { + len = 0; + } else { + /* + * If ld doesn't have a pointer to a receive_buf function, + * flush the data, then act like the ld doesn't have any + * space to put the data right now. + */ + if (!ld->ops->receive_buf) { + writew(head, &(bs->rx_tail)); + len = 0; + } + } + + if (len <= 0) { + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_READ(("dgap_input 1 - finish\n")); + if (ld) + tty_ldisc_deref(ld); + return; + } + + buf = ch->ch_bd->flipbuf; + n = len; + + /* + * n now contains the most amount of data we can copy, + * bounded either by our buffer size or the amount + * of data the card actually has pending... + */ + while (n) { + + s = ((head >= tail) ? head : ch->ch_rsize) - tail; + s = min(s, n); + + if (s <= 0) + break; + + memcpy_fromio(buf, (char *) ch->ch_raddr + tail, s); + dgap_sniff_nowait_nolock(ch, "USER READ", buf, s); + + tail += s; + buf += s; + + n -= s; + /* Flip queue if needed */ + tail &= rmask; + } + + writew(tail, &(bs->rx_tail)); + writeb(1, &(bs->idata)); + ch->ch_rxcount += len; + + /* + * If we are completely raw, we don't need to go through a lot + * of the tty layers that exist. + * In this case, we take the shortest and fastest route we + * can to relay the data to the user. + * + * On the other hand, if we are not raw, we need to go through + * the tty layer, which has its API more well defined. + */ + if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { + dgap_parity_scan(ch, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, &len); + + len = tty_buffer_request_room(tp->port, len); + tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf, + ch->ch_bd->flipflagbuf, len); + } + else { + len = tty_buffer_request_room(tp->port, len); + tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + /* Tell the tty layer its okay to "eat" the data now */ + tty_flip_buffer_push(tp->port); + + if (ld) + tty_ldisc_deref(ld); + + DPR_READ(("dgap_input - finish\n")); +} + + +/************************************************************************ + * Determines when CARRIER changes state and takes appropriate + * action. + ************************************************************************/ +void dgap_carrier(struct channel_t *ch) +{ + struct board_t *bd; + + int virt_carrier = 0; + int phys_carrier = 0; + + DPR_CARR(("dgap_carrier called...\n")); + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + /* Make sure altpin is always set correctly */ + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) { + ch->ch_dsr = DM_CD; + ch->ch_cd = DM_DSR; + } + else { + ch->ch_dsr = DM_DSR; + ch->ch_cd = DM_CD; + } + + if (ch->ch_mistat & D_CD(ch)) { + DPR_CARR(("mistat: %x D_CD: %x\n", ch->ch_mistat, D_CD(ch))); + phys_carrier = 1; + } + + if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) { + virt_carrier = 1; + } + + if (ch->ch_c_cflag & CLOCAL) { + virt_carrier = 1; + } + + + DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); + + /* + * Test for a VIRTUAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { + + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ + + DPR_CARR(("carrier: virt DCD rose\n")); + + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } + + /* + * Test for a PHYSICAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { + + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ + + DPR_CARR(("carrier: physical DCD rose\n")); + + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } + + /* + * Test for a PHYSICAL transition to low, so long as we aren't + * currently ignoring physical transitions (which is what "virtual + * carrier" indicates). + * + * The transition of the virtual carrier to low really doesn't + * matter... it really only means "ignore carrier state", not + * "make pretend that carrier is there". + */ + if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && + (phys_carrier == 0)) + { + + /* + * When carrier drops: + * + * Drop carrier on all open units. + * + * Flush queues, waking up any task waiting in the + * line discipline. + * + * Send a hangup to the control terminal. + * + * Enable all select calls. + */ + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + + if (ch->ch_tun.un_open_count > 0) { + DPR_CARR(("Sending tty hangup\n")); + tty_hangup(ch->ch_tun.un_tty); + } + + if (ch->ch_pun.un_open_count > 0) { + DPR_CARR(("Sending pr hangup\n")); + tty_hangup(ch->ch_pun.un_tty); + } + } + + /* + * Make sure that our cached values reflect the current reality. + */ + if (virt_carrier == 1) + ch->ch_flags |= CH_FCAR; + else + ch->ch_flags &= ~CH_FCAR; + + if (phys_carrier == 1) + ch->ch_flags |= CH_CD; + else + ch->ch_flags &= ~CH_CD; +} + + +/************************************************************************ + * + * TTY Entry points and helper functions + * + ************************************************************************/ + +/* + * dgap_tty_open() + * + */ +static int dgap_tty_open(struct tty_struct *tty, struct file *file) +{ + struct board_t *brd; + struct channel_t *ch; + struct un_t *un; + struct bs_t *bs; + uint major = 0; + uint minor = 0; + int rc = 0; + ulong lock_flags; + ulong lock_flags2; + u16 head; + + rc = 0; + + major = MAJOR(tty_devnum(tty)); + minor = MINOR(tty_devnum(tty)); + + if (major > 255) { + return -ENXIO; + } + + /* Get board pointer from our array of majors we have allocated */ + brd = dgap_BoardsByMajor[major]; + if (!brd) { + return -ENXIO; + } + + /* + * If board is not yet up to a state of READY, go to + * sleep waiting for it to happen or they cancel the open. + */ + rc = wait_event_interruptible(brd->state_wait, + (brd->state & BOARD_READY)); + + if (rc) { + return rc; + } + + DGAP_LOCK(brd->bd_lock, lock_flags); + + /* The wait above should guarantee this cannot happen */ + if (brd->state != BOARD_READY) { + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + /* If opened device is greater than our number of ports, bail. */ + if (MINOR(tty_devnum(tty)) > brd->nasync) { + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + ch = brd->channels[minor]; + if (!ch) { + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + /* Grab channel lock */ + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* Figure out our type */ + if (major == brd->dgap_Serial_Major) { + un = &brd->channels[minor]->ch_tun; + un->un_type = DGAP_SERIAL; + } + else if (major == brd->dgap_TransparentPrint_Major) { + un = &brd->channels[minor]->ch_pun; + un->un_type = DGAP_PRINT; + } + else { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(brd->bd_lock, lock_flags); + DPR_OPEN(("%d Unknown TYPE!\n", __LINE__)); + return -ENXIO; + } + + /* Store our unit into driver_data, so we always have it available. */ + tty->driver_data = un; + + DPR_OPEN(("Open called. MAJOR: %d MINOR:%d unit: %p NAME: %s\n", + MAJOR(tty_devnum(tty)), MINOR(tty_devnum(tty)), un, brd->name)); + + /* + * Error if channel info pointer is NULL. + */ + bs = ch->ch_bs; + if (!bs) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(brd->bd_lock, lock_flags); + DPR_OPEN(("%d BS is 0!\n", __LINE__)); + return -ENXIO; + } + + DPR_OPEN(("%d: tflag=%x pflag=%x\n", __LINE__, ch->ch_tun.un_flags, ch->ch_pun.un_flags)); + + /* + * Initialize tty's + */ + if (!(un->un_flags & UN_ISOPEN)) { + /* Store important variables. */ + un->un_tty = tty; + + /* Maybe do something here to the TTY struct as well? */ + } + + /* + * Initialize if neither terminal or printer is open. + */ + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { + + DPR_OPEN(("dgap_open: initializing channel in open...\n")); + + ch->ch_mforce = 0; + ch->ch_mval = 0; + + /* + * Flush input queue. + */ + head = readw(&(bs->rx_head)); + writew(head, &(bs->rx_tail)); + + ch->ch_flags = 0; + ch->pscan_state = 0; + ch->pscan_savechar = 0; + + ch->ch_c_cflag = tty->termios.c_cflag; + ch->ch_c_iflag = tty->termios.c_iflag; + ch->ch_c_oflag = tty->termios.c_oflag; + ch->ch_c_lflag = tty->termios.c_lflag; + ch->ch_startc = tty->termios.c_cc[VSTART]; + ch->ch_stopc = tty->termios.c_cc[VSTOP]; + + /* TODO: flush our TTY struct here? */ + } + + dgap_carrier(ch); + /* + * Run param in case we changed anything + */ + dgap_param(tty); + + /* + * follow protocol for opening port + */ + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(brd->bd_lock, lock_flags); + + rc = dgap_block_til_ready(tty, file, ch); + + if (!un->un_tty) { + return -ENODEV; + } + + if (rc) { + DPR_OPEN(("dgap_tty_open returning after dgap_block_til_ready " + "with %d\n", rc)); + } + + /* No going back now, increment our unit and channel counters */ + DGAP_LOCK(ch->ch_lock, lock_flags); + ch->ch_open_count++; + un->un_open_count++; + un->un_flags |= (UN_ISOPEN); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("dgap_tty_open finished\n")); + return (rc); +} + + +/* + * dgap_block_til_ready() + * + * Wait for DCD, if needed. + */ +static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) +{ + int retval = 0; + struct un_t *un = NULL; + ulong lock_flags; + uint old_flags = 0; + int sleep_on_un_flags = 0; + + if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGAP_CHANNEL_MAGIC) { + return (-ENXIO); + } + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) { + return (-ENXIO); + } + + DPR_OPEN(("dgap_block_til_ready - before block.\n")); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + ch->ch_wopen++; + + /* Loop forever */ + while (1) { + + sleep_on_un_flags = 0; + + /* + * If board has failed somehow during our sleep, bail with error. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + retval = -ENXIO; + break; + } + + /* If tty was hung up, break out of loop and set error. */ + if (tty_hung_up_p(file)) { + retval = -EAGAIN; + break; + } + + /* + * If either unit is in the middle of the fragile part of close, + * we just cannot touch the channel safely. + * Go back to sleep, knowing that when the channel can be + * touched safely, the close routine will signal the + * ch_wait_flags to wake us back up. + */ + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { + + /* + * Our conditions to leave cleanly and happily: + * 1) NONBLOCKING on the tty is set. + * 2) CLOCAL is set. + * 3) DCD (fake or real) is active. + */ + + if (file->f_flags & O_NONBLOCK) { + break; + } + + if (tty->flags & (1 << TTY_IO_ERROR)) { + break; + } + + if (ch->ch_flags & CH_CD) { + DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); + break; + } + + if (ch->ch_flags & CH_FCAR) { + DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); + break; + } + } + else { + sleep_on_un_flags = 1; + } + + /* + * If there is a signal pending, the user probably + * interrupted (ctrl-c) us. + * Leave loop with error set. + */ + if (signal_pending(current)) { + DPR_OPEN(("%d: signal pending...\n", __LINE__)); + retval = -ERESTARTSYS; + break; + } + + DPR_OPEN(("dgap_block_til_ready - blocking.\n")); + + /* + * Store the flags before we let go of channel lock + */ + if (sleep_on_un_flags) + old_flags = ch->ch_tun.un_flags | ch->ch_pun.un_flags; + else + old_flags = ch->ch_flags; + + /* + * Let go of channel lock before calling schedule. + * Our poller will get any FEP events and wake us up when DCD + * eventually goes active. + */ + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("Going to sleep on %s flags...\n", + (sleep_on_un_flags ? "un" : "ch"))); + + /* + * Wait for something in the flags to change from the current value. + */ + if (sleep_on_un_flags) { + retval = wait_event_interruptible(un->un_flags_wait, + (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); + } + else { + retval = wait_event_interruptible(ch->ch_flags_wait, + (old_flags != ch->ch_flags)); + } + + DPR_OPEN(("After sleep... retval: %x\n", retval)); + + /* + * We got woken up for some reason. + * Before looping around, grab our channel lock. + */ + DGAP_LOCK(ch->ch_lock, lock_flags); + } + + ch->ch_wopen--; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("dgap_block_til_ready - after blocking.\n")); + + if (retval) { + DPR_OPEN(("dgap_block_til_ready - done. error. retval: %x\n", retval)); + return(retval); + } + + DPR_OPEN(("dgap_block_til_ready - done no error. jiffies: %lu\n", jiffies)); + + return(0); +} + + +/* + * dgap_tty_hangup() + * + * Hangup the port. Like a close, but don't wait for output to drain. + */ +static void dgap_tty_hangup(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_CLOSE(("dgap_hangup called. ch->ch_open_count: %d un->un_open_count: %d\n", + ch->ch_open_count, un->un_open_count)); + + /* flush the transmit queues */ + dgap_tty_flush_buffer(tty); + + DPR_CLOSE(("dgap_hangup finished. ch->ch_open_count: %d un->un_open_count: %d\n", + ch->ch_open_count, un->un_open_count)); +} + + + +/* + * dgap_tty_close() + * + */ +static void dgap_tty_close(struct tty_struct *tty, struct file *file) +{ + struct ktermios *ts; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + int rc = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + ts = &tty->termios; + + DPR_CLOSE(("Close called\n")); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + /* + * Determine if this is the last close or not - and if we agree about + * which type of close it is with the Line Discipline + */ + if ((tty->count == 1) && (un->un_open_count != 1)) { + /* + * Uh, oh. tty->count is 1, which means that the tty + * structure will be freed. un_open_count should always + * be one in these conditions. If it's greater than + * one, we've got real problems, since it means the + * serial port won't be shutdown. + */ + APR(("tty->count is 1, un open count is %d\n", un->un_open_count)); + un->un_open_count = 1; + } + + if (--un->un_open_count < 0) { + APR(("bad serial port open count of %d\n", un->un_open_count)); + un->un_open_count = 0; + } + + ch->ch_open_count--; + + if (ch->ch_open_count && un->un_open_count) { + DPR_CLOSE(("dgap_tty_close: not last close ch: %d un:%d\n", + ch->ch_open_count, un->un_open_count)); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* OK, its the last close on the unit */ + DPR_CLOSE(("dgap_tty_close - last close on unit procedures\n")); + + un->un_flags |= UN_CLOSING; + + tty->closing = 1; + + /* + * Only officially close channel if count is 0 and + * DIGI_PRINTER bit is not set. + */ + if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { + + ch->ch_flags &= ~(CH_RXBLOCK); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + /* wait for output to drain */ + /* This will also return if we take an interrupt */ + + DPR_CLOSE(("Calling wait_for_drain\n")); + rc = dgap_wait_for_drain(tty); + DPR_CLOSE(("After calling wait_for_drain\n")); + + if (rc) { + DPR_BASIC(("dgap_tty_close - bad return: %d ", rc)); + } + + dgap_tty_flush_buffer(tty); + tty_ldisc_flush(tty); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + tty->closing = 0; + + /* + * If we have HUPCL set, lower DTR and RTS + */ + if (ch->ch_c_cflag & HUPCL ) { + DPR_CLOSE(("Close. HUPCL set, dropping DTR/RTS\n")); + ch->ch_mostat &= ~(D_RTS(ch)|D_DTR(ch)); + dgap_cmdb( ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0 ); + + /* + * Go to sleep to ensure RTS/DTR + * have been dropped for modems to see it. + */ + if (ch->ch_close_delay) { + DPR_CLOSE(("Close. Sleeping for RTS/DTR drop\n")); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + dgap_ms_sleep(ch->ch_close_delay); + DGAP_LOCK(ch->ch_lock, lock_flags); + + DPR_CLOSE(("Close. After sleeping for RTS/DTR drop\n")); + } + } + + ch->pscan_state = 0; + ch->pscan_savechar = 0; + ch->ch_baud_info = 0; + + } + + /* + * turn off print device when closing print device. + */ + if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON) ) { + dgap_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + ch->ch_flags &= ~CH_PRON; + } + + un->un_tty = NULL; + un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); + tty->driver_data = NULL; + + DPR_CLOSE(("Close. Doing wakeups\n")); + wake_up_interruptible(&ch->ch_flags_wait); + wake_up_interruptible(&un->un_flags_wait); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_BASIC(("dgap_tty_close - complete\n")); +} + + +/* + * dgap_tty_chars_in_buffer() + * + * Return number of characters that have not been transmitted yet. + * + * This routine is used by the line discipline to determine if there + * is data waiting to be transmitted/drained/flushed or not. + */ +static int dgap_tty_chars_in_buffer(struct tty_struct *tty) +{ + struct board_t *bd = NULL; + struct channel_t *ch = NULL; + struct un_t *un = NULL; + struct bs_t *bs = NULL; + uchar tbusy; + uint chars = 0; + u16 thead, ttail, tmask, chead, ctail; + ulong lock_flags = 0; + ulong lock_flags2 = 0; + + if (tty == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + + bs = ch->ch_bs; + if (!bs) + return (0); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + tmask = (ch->ch_tsize - 1); + + /* Get Transmit queue pointers */ + thead = readw(&(bs->tx_head)) & tmask; + ttail = readw(&(bs->tx_tail)) & tmask; + + /* Get tbusy flag */ + tbusy = readb(&(bs->tbusy)); + + /* Get Command queue pointers */ + chead = readw(&(ch->ch_cm->cm_head)); + ctail = readw(&(ch->ch_cm->cm_tail)); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + /* + * The only way we know for sure if there is no pending + * data left to be transferred, is if: + * 1) Transmit head and tail are equal (empty). + * 2) Command queue head and tail are equal (empty). + * 3) The "TBUSY" flag is 0. (Transmitter not busy). + */ + + if ((ttail == thead) && (tbusy == 0) && (chead == ctail)) { + chars = 0; + } + else { + if (thead >= ttail) + chars = thead - ttail; + else + chars = thead - ttail + ch->ch_tsize; + /* + * Fudge factor here. + * If chars is zero, we know that the command queue had + * something in it or tbusy was set. Because we cannot + * be sure if there is still some data to be transmitted, + * lets lie, and tell ld we have 1 byte left. + */ + if (chars == 0) { + /* + * If TBUSY is still set, and our tx buffers are empty, + * force the firmware to send me another wakeup after + * TBUSY has been cleared. + */ + if (tbusy != 0) { + DGAP_LOCK(ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + } + chars = 1; + } + } + + DPR_WRITE(("dgap_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d tsize: %d)\n", + ch->ch_portnum, chars, thead, ttail, ch->ch_tsize)); + return(chars); +} + + +static int dgap_wait_for_drain(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + struct bs_t *bs; + int ret = -EIO; + uint count = 1; + ulong lock_flags = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bs = ch->ch_bs; + if (!bs) + return ret; + + ret = 0; + + DPR_DRAIN(("dgap_wait_for_drain start\n")); + + /* Loop until data is drained */ + while (count != 0) { + + count = dgap_tty_chars_in_buffer(tty); + + if (count == 0) + break; + + /* Set flag waiting for drain */ + DGAP_LOCK(ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + /* Go to sleep till we get woken up */ + ret = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0)); + /* If ret is non-zero, user ctrl-c'ed us */ + if (ret) { + break; + } + } + + DGAP_LOCK(ch->ch_lock, lock_flags); + un->un_flags &= ~(UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_DRAIN(("dgap_wait_for_drain finish\n")); + return (ret); +} + + +/* + * dgap_maxcps_room + * + * Reduces bytes_available to the max number of characters + * that can be sent currently given the maxcps value, and + * returns the new bytes_available. This only affects printer + * output. + */ +static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + + if (tty == NULL) + return (bytes_available); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (bytes_available); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (bytes_available); + + /* + * If its not the Transparent print device, return + * the full data amount. + */ + if (un->un_type != DGAP_PRINT) + return (bytes_available); + + if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0 ) { + int cps_limit = 0; + unsigned long current_time = jiffies; + unsigned long buffer_time = current_time + + (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps; + + if (ch->ch_cpstime < current_time) { + /* buffer is empty */ + ch->ch_cpstime = current_time; /* reset ch_cpstime */ + cps_limit = ch->ch_digi.digi_bufsize; + } + else if (ch->ch_cpstime < buffer_time) { + /* still room in the buffer */ + cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; + } + else { + /* no room in the buffer */ + cps_limit = 0; + } + + bytes_available = min(cps_limit, bytes_available); + } + + return (bytes_available); +} + + +static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) +{ + struct channel_t *ch = NULL; + struct bs_t *bs = NULL; + + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + bs = ch->ch_bs; + if (!bs) + return; + + if ((event & UN_LOW) != 0) { + if ((un->un_flags & UN_LOW) == 0) { + un->un_flags |= UN_LOW; + writeb(1, &(bs->ilow)); + } + } + if ((event & UN_LOW) != 0) { + if ((un->un_flags & UN_EMPTY) == 0) { + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + } + } +} + + +/* + * dgap_tty_write_room() + * + * Return space available in Tx buffer + */ +static int dgap_tty_write_room(struct tty_struct *tty) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + struct bs_t *bs = NULL; + u16 head, tail, tmask; + int ret = 0; + ulong lock_flags = 0; + + if (tty == NULL || dgap_TmpWriteBuf == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + + bs = ch->ch_bs; + if (!bs) + return (0); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + tmask = ch->ch_tsize - 1; + head = readw(&(bs->tx_head)) & tmask; + tail = readw(&(bs->tx_tail)) & tmask; + + if ((ret = tail - head - 1) < 0) + ret += ch->ch_tsize; + + /* Limit printer to maxcps */ + ret = dgap_maxcps_room(tty, ret); + + /* + * If we are printer device, leave space for + * possibly both the on and off strings. + */ + if (un->un_type == DGAP_PRINT) { + if (!(ch->ch_flags & CH_PRON)) + ret -= ch->ch_digi.digi_onlen; + ret -= ch->ch_digi.digi_offlen; + } + else { + if (ch->ch_flags & CH_PRON) + ret -= ch->ch_digi.digi_offlen; + } + + if (ret < 0) + ret = 0; + + /* + * Schedule FEP to wake us up if needed. + * + * TODO: This might be overkill... + * Do we really need to schedule callbacks from the FEP + * in every case? Can we get smarter based on ret? + */ + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_WRITE(("dgap_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); + + return(ret); +} + + +/* + * dgap_tty_put_char() + * + * Put a character into ch->ch_buf + * + * - used by the line discipline for OPOST processing + */ +static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c) +{ + /* + * Simply call tty_write. + */ + DPR_WRITE(("dgap_tty_put_char called\n")); + dgap_tty_write(tty, &c, 1); + return 1; +} + + +/* + * dgap_tty_write() + * + * Take data from the user or kernel and send it out to the FEP. + * In here exists all the Transparent Print magic as well. + */ +static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + struct bs_t *bs = NULL; + char *vaddr = NULL; + u16 head, tail, tmask, remain; + int bufcount = 0, n = 0; + int orig_count = 0; + ulong lock_flags; + int from_user = 0; + + if (tty == NULL || dgap_TmpWriteBuf == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return(0); + + bs = ch->ch_bs; + if (!bs) + return(0); + + if (!count) + return(0); + + DPR_WRITE(("dgap_tty_write: Port: %x tty=%p user=%d len=%d\n", + ch->ch_portnum, tty, from_user, count)); + + /* + * Store original amount of characters passed in. + * This helps to figure out if we should ask the FEP + * to send us an event when it has more space available. + */ + orig_count = count; + + DGAP_LOCK(ch->ch_lock, lock_flags); + + /* Get our space available for the channel from the board */ + tmask = ch->ch_tsize - 1; + head = readw(&(bs->tx_head)) & tmask; + tail = readw(&(bs->tx_tail)) & tmask; + + if ((bufcount = tail - head - 1) < 0) + bufcount += ch->ch_tsize; + + DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n", + __LINE__, bufcount, count, tail, head, tmask)); + + /* + * Limit printer output to maxcps overall, with bursts allowed + * up to bufsize characters. + */ + bufcount = dgap_maxcps_room(tty, bufcount); + + /* + * Take minimum of what the user wants to send, and the + * space available in the FEP buffer. + */ + count = min(count, bufcount); + + /* + * Bail if no space left. + */ + if (count <= 0) { + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + /* + * Output the printer ON string, if we are in terminal mode, but + * need to be in printer mode. + */ + if ((un->un_type == DGAP_PRINT) && !(ch->ch_flags & CH_PRON)) { + dgap_wmove(ch, ch->ch_digi.digi_onstr, + (int) ch->ch_digi.digi_onlen); + head = readw(&(bs->tx_head)) & tmask; + ch->ch_flags |= CH_PRON; + } + + /* + * On the other hand, output the printer OFF string, if we are + * currently in printer mode, but need to output to the terminal. + */ + if ((un->un_type != DGAP_PRINT) && (ch->ch_flags & CH_PRON)) { + dgap_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + head = readw(&(bs->tx_head)) & tmask; + ch->ch_flags &= ~CH_PRON; + } + + /* + * If there is nothing left to copy, or I can't handle any more data, leave. + */ + if (count <= 0) { + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + if (from_user) { + + count = min(count, WRITEBUFLEN); + + DGAP_UNLOCK(ch->ch_lock, 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(&dgap_TmpWriteSem)) { + return (-EINTR); + } + + if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { + up(&dgap_TmpWriteSem); + printk("Write: Copy from user failed!\n"); + return -EFAULT; + } + + DGAP_LOCK(ch->ch_lock, lock_flags); + + buf = dgap_TmpWriteBuf; + } + + n = count; + + /* + * If the write wraps over the top of the circular buffer, + * move the portion up to the wrap point, and reset the + * pointers to the bottom. + */ + remain = ch->ch_tstart + ch->ch_tsize - head; + + if (n >= remain) { + n -= remain; + vaddr = ch->ch_taddr + head; + + memcpy_toio(vaddr, (uchar *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, remain); + + head = ch->ch_tstart; + buf += remain; + } + + if (n > 0) { + + /* + * Move rest of data. + */ + vaddr = ch->ch_taddr + head; + remain = n; + + memcpy_toio(vaddr, (uchar *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, remain); + + head += remain; + + } + + if (count) { + ch->ch_txcount += count; + head &= tmask; + writew(head, &(bs->tx_head)); + } + + + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + + /* + * If this is the print device, and the + * printer is still on, we need to turn it + * off before going idle. If the buffer is + * non-empty, wait until it goes empty. + * Otherwise turn it off right now. + */ + if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON)) { + tail = readw(&(bs->tx_tail)) & tmask; + + if (tail != head) { + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + } + else { + dgap_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + head = readw(&(bs->tx_head)) & tmask; + ch->ch_flags &= ~CH_PRON; + } + } + + /* Update printer buffer empty time. */ + if ((un->un_type == DGAP_PRINT) && (ch->ch_digi.digi_maxcps > 0) + && (ch->ch_digi.digi_bufsize > 0)) { + ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; + } + + if (from_user) { + DGAP_UNLOCK(ch->ch_lock, lock_flags); + up(&dgap_TmpWriteSem); + } + else { + DGAP_UNLOCK(ch->ch_lock, lock_flags); + } + + DPR_WRITE(("Write finished - Write %d bytes of %d.\n", count, orig_count)); + + return (count); +} + + + +/* + * Return modem signals to ld. + */ +static int dgap_tty_tiocmget(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + int result = -EIO; + uchar mstat = 0; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return result; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return result; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return result; + + DPR_IOCTL(("dgap_tty_tiocmget start\n")); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + mstat = readb(&(ch->ch_bs->m_stat)); + /* Append any outbound signals that might be pending... */ + mstat |= ch->ch_mostat; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + result = 0; + + if (mstat & D_DTR(ch)) + result |= TIOCM_DTR; + if (mstat & D_RTS(ch)) + result |= TIOCM_RTS; + if (mstat & D_CTS(ch)) + result |= TIOCM_CTS; + if (mstat & D_DSR(ch)) + result |= TIOCM_DSR; + if (mstat & D_RI(ch)) + result |= TIOCM_RI; + if (mstat & D_CD(ch)) + result |= TIOCM_CD; + + DPR_IOCTL(("dgap_tty_tiocmget finish\n")); + + return result; +} + + +/* + * dgap_tty_tiocmset() + * + * Set modem signals, called by ld. + */ + +static int dgap_tty_tiocmset(struct tty_struct *tty, + unsigned int set, unsigned int clear) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -EIO; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return ret; + + DPR_IOCTL(("dgap_tty_tiocmset start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if (set & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval |= D_RTS(ch); + } + + if (set & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval |= D_DTR(ch); + } + + if (clear & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval &= ~(D_RTS(ch)); + } + + if (clear & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval &= ~(D_DTR(ch)); + } + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_tiocmset finish\n")); + + return (0); +} + + + +/* + * dgap_tty_send_break() + * + * Send a Break, called by ld. + */ +static int dgap_tty_send_break(struct tty_struct *tty, int msec) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -EIO; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return ret; + + switch (msec) { + case -1: + msec = 0xFFFF; + break; + case 0: + msec = 1; + break; + default: + msec /= 10; + break; + } + + DPR_IOCTL(("dgap_tty_send_break start 1. %lx\n", jiffies)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); +#if 0 + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); +#endif + dgap_cmdw(ch, SBREAK, (u16) msec, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_send_break finish\n")); + + return (0); +} + + + + +/* + * dgap_tty_wait_until_sent() + * + * wait until data has been transmitted, called by ld. + */ +static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout) +{ + int rc; + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return; + } + return; +} + + + +/* + * dgap_send_xchar() + * + * send a high priority character, called by ld. + */ +static void dgap_tty_send_xchar(struct tty_struct *tty, char c) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_send_xchar start 1. %lx\n", jiffies)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* + * This is technically what we should do. + * However, the NIST tests specifically want + * to see each XON or XOFF character that it + * sends, so lets just send each character + * by hand... + */ +#if 0 + if (c == STOP_CHAR(tty)) { + dgap_cmdw(ch, RPAUSE, 0, 0); + } + else if (c == START_CHAR(tty)) { + dgap_cmdw(ch, RRESUME, 0, 0); + } + else { + dgap_wmove(ch, &c, 1); + } +#else + dgap_wmove(ch, &c, 1); +#endif + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_send_xchar finish\n")); + + return; +} + + + + +/* + * Return modem signals to ld. + */ +static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) +{ + int result = 0; + uchar mstat = 0; + ulong lock_flags; + int rc = 0; + + DPR_IOCTL(("dgap_get_modem_info start\n")); + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return(-ENXIO); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + mstat = readb(&(ch->ch_bs->m_stat)); + /* Append any outbound signals that might be pending... */ + mstat |= ch->ch_mostat; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + result = 0; + + if (mstat & D_DTR(ch)) + result |= TIOCM_DTR; + if (mstat & D_RTS(ch)) + result |= TIOCM_RTS; + if (mstat & D_CTS(ch)) + result |= TIOCM_CTS; + if (mstat & D_DSR(ch)) + result |= TIOCM_DSR; + if (mstat & D_RI(ch)) + result |= TIOCM_RI; + if (mstat & D_CD(ch)) + result |= TIOCM_CD; + + rc = put_user(result, value); + + DPR_IOCTL(("dgap_get_modem_info finish\n")); + return(rc); +} + + +/* + * dgap_set_modem_info() + * + * Set modem signals, called by ld. + */ +static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -ENXIO; + unsigned int arg = 0; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return ret; + + DPR_IOCTL(("dgap_set_modem_info() start\n")); + + ret = get_user(arg, value); + if (ret) { + DPR_IOCTL(("dgap_set_modem_info %d ret: %x. finished.\n", __LINE__, ret)); + return(ret); + } + + DPR_IOCTL(("dgap_set_modem_info: command: %x arg: %x\n", command, arg)); + + switch (command) { + case TIOCMBIS: + if (arg & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval |= D_RTS(ch); + } + + if (arg & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval |= D_DTR(ch); + } + + break; + + case TIOCMBIC: + if (arg & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval &= ~(D_RTS(ch)); + } + + if (arg & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval &= ~(D_DTR(ch)); + } + + break; + + case TIOCMSET: + ch->ch_mforce = D_DTR(ch)|D_RTS(ch); + + if (arg & TIOCM_RTS) { + ch->ch_mval |= D_RTS(ch); + } + else { + ch->ch_mval &= ~(D_RTS(ch)); + } + + if (arg & TIOCM_DTR) { + ch->ch_mval |= (D_DTR(ch)); + } + else { + ch->ch_mval &= ~(D_DTR(ch)); + } + + break; + + default: + return(-EINVAL); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_set_modem_info finish\n")); + + return (0); +} + + +/* + * dgap_tty_digigeta() + * + * Ioctl to get the information for ditty. + * + * + * + */ +static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + struct digi_t tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGAP_LOCK(ch->ch_lock, lock_flags); + memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgap_tty_digiseta() + * + * Ioctl to set the information for ditty. + * + * + * + */ +static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + struct digi_t new_digi; + ulong lock_flags = 0; + unsigned long lock_flags2; + + DPR_IOCTL(("DIGI_SETA start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-EFAULT); + + if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) { + DPR_IOCTL(("DIGI_SETA failed copy_from_user\n")); + return(-EFAULT); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t)); + + if (ch->ch_digi.digi_maxcps < 1) + ch->ch_digi.digi_maxcps = 1; + + if (ch->ch_digi.digi_maxcps > 10000) + ch->ch_digi.digi_maxcps = 10000; + + if (ch->ch_digi.digi_bufsize < 10) + ch->ch_digi.digi_bufsize = 10; + + if (ch->ch_digi.digi_maxchar < 1) + ch->ch_digi.digi_maxchar = 1; + + if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize) + ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize; + + if (ch->ch_digi.digi_onlen > DIGI_PLEN) + ch->ch_digi.digi_onlen = DIGI_PLEN; + + if (ch->ch_digi.digi_offlen > DIGI_PLEN) + ch->ch_digi.digi_offlen = DIGI_PLEN; + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("DIGI_SETA finish\n")); + + return(0); +} + + +/* + * dgap_tty_digigetedelay() + * + * Ioctl to get the current edelay setting. + * + * + * + */ +static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + int tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGAP_LOCK(ch->ch_lock, lock_flags); + tmp = readw(&(ch->ch_bs->edelay)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgap_tty_digisetedelay() + * + * Ioctl to set the EDELAY setting + * + */ +static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int new_digi; + ulong lock_flags; + ulong lock_flags2; + + DPR_IOCTL(("DIGI_SETA start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-EFAULT); + + if (copy_from_user(&new_digi, new_info, sizeof(int))) { + DPR_IOCTL(("DIGI_SETEDELAY failed copy_from_user\n")); + return(-EFAULT); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + writew((u16) new_digi, &(ch->ch_bs->edelay)); + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("DIGI_SETA finish\n")); + + return(0); +} + + +/* + * dgap_tty_digigetcustombaud() + * + * Ioctl to get the current custom baud rate setting. + */ +static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + int tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGAP_LOCK(ch->ch_lock, lock_flags); + tmp = dgap_get_custom_baud(ch); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("DIGI_GETCUSTOMBAUD. Returning %d\n", tmp)); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgap_tty_digisetcustombaud() + * + * Ioctl to set the custom baud rate setting + */ +static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + uint new_rate; + ulong lock_flags; + ulong lock_flags2; + + DPR_IOCTL(("DIGI_SETCUSTOMBAUD start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-EFAULT); + + + if (copy_from_user(&new_rate, new_info, sizeof(unsigned int))) { + DPR_IOCTL(("DIGI_SETCUSTOMBAUD failed copy_from_user\n")); + return(-EFAULT); + } + + if (bd->bd_flags & BD_FEP5PLUS) { + + DPR_IOCTL(("DIGI_SETCUSTOMBAUD. Setting %d\n", new_rate)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_custom_speed = new_rate; + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + } + + DPR_IOCTL(("DIGI_SETCUSTOMBAUD finish\n")); + + return(0); +} + + +/* + * dgap_set_termios() + */ +static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + unsigned long lock_flags; + unsigned long lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_c_cflag = tty->termios.c_cflag; + ch->ch_c_iflag = tty->termios.c_iflag; + ch->ch_c_oflag = tty->termios.c_oflag; + ch->ch_c_lflag = tty->termios.c_lflag; + ch->ch_startc = tty->termios.c_cc[VSTART]; + ch->ch_stopc = tty->termios.c_cc[VSTOP]; + + dgap_carrier(ch); + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); +} + + +static void dgap_tty_throttle(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_throttle start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_flags |= (CH_RXBLOCK); +#if 1 + dgap_cmdw(ch, RPAUSE, 0, 0); +#endif + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_throttle finish\n")); +} + + +static void dgap_tty_unthrottle(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_unthrottle start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_flags &= ~(CH_RXBLOCK); + +#if 1 + dgap_cmdw(ch, RRESUME, 0, 0); +#endif + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_unthrottle finish\n")); +} + + +static void dgap_tty_start(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_start start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, RESUMETX, 0, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_start finish\n")); +} + + +static void dgap_tty_stop(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_stop start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, PAUSETX, 0, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_stop finish\n")); +} + + +/* + * dgap_tty_flush_chars() + * + * Flush the cook buffer + * + * Note to self, and any other poor souls who venture here: + * + * flush in this case DOES NOT mean dispose of the data. + * instead, it means "stop buffering and send it if you + * haven't already." Just guess how I figured that out... SRW 2-Jun-98 + * + * It is also always called in interrupt context - JAR 8-Sept-99 + */ +static void dgap_tty_flush_chars(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_flush_chars start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* TODO: Do something here */ + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_flush_chars finish\n")); +} + + + +/* + * dgap_tty_flush_buffer() + * + * Flush Tx buffer (make in == out) + */ +static void dgap_tty_flush_buffer(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + u16 head = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_flush_buffer on port: %d start\n", ch->ch_portnum)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->tx_head)); + dgap_cmdw(ch, FLUSHTX, (u16) head, 0); + dgap_cmdw(ch, RESUMETX, 0, 0); + if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (waitqueue_active(&tty->write_wait)) + wake_up_interruptible(&tty->write_wait); + tty_wakeup(tty); + + DPR_IOCTL(("dgap_tty_flush_buffer finish\n")); +} + + + +/***************************************************************************** + * + * The IOCTL function and all of its helpers + * + *****************************************************************************/ + +/* + * dgap_tty_ioctl() + * + * The usual assortment of ioctl's + */ +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, + unsigned long arg) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int rc; + u16 head = 0; + ulong lock_flags = 0; + ulong lock_flags2 = 0; + void __user *uarg = (void __user *) arg; + + if (!tty || tty->magic != TTY_MAGIC) + return (-ENODEV); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-ENODEV); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-ENODEV); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-ENODEV); + + DPR_IOCTL(("dgap_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if (un->un_open_count <= 0) { + DPR_BASIC(("dgap_tty_ioctl - unit not open.\n")); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(-EIO); + } + + switch (cmd) { + + /* Here are all the standard ioctl's that we MUST implement */ + + case TCSBRK: + /* + * TCSBRK is SVID version: non-zero arg --> no break + * this behaviour is exploited by tcdrain(). + * + * According to POSIX.1 spec (7.2.2.1.2) breaks should be + * between 0.25 and 0.5 seconds so we'll ask for something + * in the middle: 0.375 seconds. + */ + rc = tty_check_change(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = dgap_wait_for_drain(tty); + + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if(((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(0); + + + case TCSBRKP: + /* support for POSIX tcsendbreak() + + * According to POSIX.1 spec (7.2.2.1.2) breaks should be + * between 0.25 and 0.5 seconds so we'll ask for something + * in the middle: 0.375 seconds. + */ + rc = tty_check_change(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(0); + + case TIOCSBRK: + /* + * FEP5 doesn't support turning on a break unconditionally. + * The FEP5 device will stop sending a break automatically + * after the specified time value that was sent when turning on + * the break. + */ + rc = tty_check_change(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return 0; + + case TIOCCBRK: + /* + * FEP5 doesn't support turning off a break unconditionally. + * The FEP5 device will stop sending a break automatically + * after the specified time value that was sent when turning on + * the break. + */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return 0; + + case TIOCGSOFTCAR: + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); + return(rc); + + case TIOCSSOFTCAR: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + rc = get_user(arg, (unsigned long __user *) arg); + if (rc) + return(rc); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); + dgap_param(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + return(0); + + case TIOCMGET: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_get_modem_info(ch, uarg)); + + case TIOCMBIS: + case TIOCMBIC: + case TIOCMSET: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_set_modem_info(tty, cmd, uarg)); + + /* + * Here are any additional ioctl's that we want to implement + */ + + case TCFLSH: + /* + * The linux tty driver doesn't have a flush + * input routine for the driver, assuming all backed + * up data is in the line disc. buffers. However, + * we all know that's not the case. Here, we + * act on the ioctl, but then lie and say we didn't + * so the line discipline will process the flush + * also. + */ + rc = tty_check_change(tty); + if (rc) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(rc); + } + + if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) { + if (!(un->un_type == DGAP_PRINT)) { + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + writeb(0, &(ch->ch_bs->orun)); + } + } + + if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) { + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->tx_head)); + dgap_cmdw(ch, FLUSHTX, (u16) head, 0 ); + dgap_cmdw(ch, RESUMETX, 0, 0); + if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + if (waitqueue_active(&tty->write_wait)) + wake_up_interruptible(&tty->write_wait); + + /* Can't hold any locks when calling tty_wakeup! */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + tty_wakeup(tty); + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + + /* pretend we didn't recognize this IOCTL */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", + __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + + case TCSETSF: + case TCSETSW: + /* + * The linux tty driver doesn't have a flush + * input routine for the driver, assuming all backed + * up data is in the line disc. buffers. However, + * we all know that's not the case. Here, we + * act on the ioctl, but then lie and say we didn't + * so the line discipline will process the flush + * also. + */ + if (cmd == TCSETSF) { + /* flush rx */ + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + } + + /* now wait for all the output to drain */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + /* pretend we didn't recognize this */ + return(-ENOIOCTLCMD); + + case TCSETAW: + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + /* pretend we didn't recognize this */ + return(-ENOIOCTLCMD); + + case TCXONC: + /* + * The Linux Line Discipline (LD) would do this for us if we + * let it, but we have the special firmware options to do this + * the "right way" regardless of hardware or software flow + * control so we'll do it outselves instead of letting the LD + * do it. + */ + rc = tty_check_change(tty); + if (rc) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(rc); + } + + DPR_IOCTL(("dgap_ioctl - in TCXONC - %d\n", cmd)); + switch (arg) { + + case TCOON: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + dgap_tty_start(tty); + return(0); + case TCOOFF: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + dgap_tty_stop(tty); + return(0); + case TCION: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + /* Make the ld do it */ + return(-ENOIOCTLCMD); + case TCIOFF: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + /* Make the ld do it */ + return(-ENOIOCTLCMD); + default: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(-EINVAL); + } + + case DIGI_GETA: + /* get information for ditty */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digigeta(tty, uarg)); + + case DIGI_SETAW: + case DIGI_SETAF: + + /* set information for ditty */ + if (cmd == (DIGI_SETAW)) { + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + else { + tty_ldisc_flush(tty); + } + /* fall thru */ + + case DIGI_SETA: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digiseta(tty, uarg)); + + case DIGI_GEDELAY: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digigetedelay(tty, uarg)); + + case DIGI_SEDELAY: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digisetedelay(tty, uarg)); + + case DIGI_GETCUSTOMBAUD: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digigetcustombaud(tty, uarg)); + + case DIGI_SETCUSTOMBAUD: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digisetcustombaud(tty, uarg)); + + case DIGI_RESET_PORT: + dgap_firmware_reset_port(ch); + dgap_param(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return 0; + + default: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl - in default\n")); + DPR_IOCTL(("dgap_tty_ioctl end - cmd %s (%x), arg %lx\n", + dgap_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + } +} diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c deleted file mode 100644 index 9b3d3b5ed34e..000000000000 --- a/drivers/staging/dgap/dgap_tty.c +++ /dev/null @@ -1,3555 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - */ - -/************************************************************************ - * - * This file implements the tty driver functionality for the - * FEP5 based product lines. - * - ************************************************************************ - * - */ - -#include -#include /* For jiffies, task states */ -#include /* For tasklet and interrupt structs/defines */ -#include -#include -#include -#include -#include -#include -#include /* For udelay */ -#include /* For copy_from_user/copy_to_user */ -#include /* For read[bwl]/write[bwl] */ -#include - -#include "dgap_driver.h" -#include "dgap_tty.h" -#include "dgap_types.h" -#include "dgap_fep5.h" -#include "dgap_parse.h" -#include "dgap_conf.h" -#include "dgap_sysfs.h" - -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) - -/* - * internal variables - */ -static struct board_t *dgap_BoardsByMajor[256]; -static uchar *dgap_TmpWriteBuf = NULL; -static DECLARE_MUTEX(dgap_TmpWriteSem); - -/* - * Default transparent print information. - */ -static struct digi_t dgap_digi_init = { - .digi_flags = DIGI_COOK, /* Flags */ - .digi_maxcps = 100, /* Max CPS */ - .digi_maxchar = 50, /* Max chars in print queue */ - .digi_bufsize = 100, /* Printer buffer size */ - .digi_onlen = 4, /* size of printer on string */ - .digi_offlen = 4, /* size of printer off string */ - .digi_onstr = "\033[5i", /* ANSI printer on string ] */ - .digi_offstr = "\033[4i", /* ANSI printer off string ] */ - .digi_term = "ansi" /* default terminal type */ -}; - - -/* - * Define a local default termios struct. All ports will be created - * with this termios initially. - * - * This defines a raw port at 9600 baud, 8 data bits, no parity, - * 1 stop bit. - */ - -static struct ktermios DgapDefaultTermios = -{ - .c_iflag = (DEFAULT_IFLAGS), /* iflags */ - .c_oflag = (DEFAULT_OFLAGS), /* oflags */ - .c_cflag = (DEFAULT_CFLAGS), /* cflags */ - .c_lflag = (DEFAULT_LFLAGS), /* lflags */ - .c_cc = INIT_C_CC, - .c_line = 0, -}; - -/* Our function prototypes */ -static int dgap_tty_open(struct tty_struct *tty, struct file *file); -static void dgap_tty_close(struct tty_struct *tty, struct file *file); -static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); -static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); -static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); -static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); -static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo); -static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info); -static int dgap_tty_write_room(struct tty_struct* tty); -static int dgap_tty_chars_in_buffer(struct tty_struct* tty); -static void dgap_tty_start(struct tty_struct *tty); -static void dgap_tty_stop(struct tty_struct *tty); -static void dgap_tty_throttle(struct tty_struct *tty); -static void dgap_tty_unthrottle(struct tty_struct *tty); -static void dgap_tty_flush_chars(struct tty_struct *tty); -static void dgap_tty_flush_buffer(struct tty_struct *tty); -static void dgap_tty_hangup(struct tty_struct *tty); -static int dgap_wait_for_drain(struct tty_struct *tty); -static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value); -static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value); -static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info); -static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo); -static int dgap_tty_tiocmget(struct tty_struct *tty); -static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); -static int dgap_tty_send_break(struct tty_struct *tty, int msec); -static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout); -static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); -static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); -static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c); -static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); - -static const struct tty_operations dgap_tty_ops = { - .open = dgap_tty_open, - .close = dgap_tty_close, - .write = dgap_tty_write, - .write_room = dgap_tty_write_room, - .flush_buffer = dgap_tty_flush_buffer, - .chars_in_buffer = dgap_tty_chars_in_buffer, - .flush_chars = dgap_tty_flush_chars, - .ioctl = dgap_tty_ioctl, - .set_termios = dgap_tty_set_termios, - .stop = dgap_tty_stop, - .start = dgap_tty_start, - .throttle = dgap_tty_throttle, - .unthrottle = dgap_tty_unthrottle, - .hangup = dgap_tty_hangup, - .put_char = dgap_tty_put_char, - .tiocmget = dgap_tty_tiocmget, - .tiocmset = dgap_tty_tiocmset, - .break_ctl = dgap_tty_send_break, - .wait_until_sent = dgap_tty_wait_until_sent, - .send_xchar = dgap_tty_send_xchar -}; - - - - - -/************************************************************************ - * - * TTY Initialization/Cleanup Functions - * - ************************************************************************/ - -/* - * dgap_tty_preinit() - * - * Initialize any global tty related data before we download any boards. - */ -int dgap_tty_preinit(void) -{ - unsigned long flags; - - DGAP_LOCK(dgap_global_lock, flags); - - /* - * Allocate a buffer for doing the copy from user space to - * kernel space in dgap_input(). We only use one buffer and - * control access to it with a semaphore. If we are paging, we - * are already in trouble so one buffer won't hurt much anyway. - */ - dgap_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_ATOMIC); - - if (!dgap_TmpWriteBuf) { - DGAP_UNLOCK(dgap_global_lock, flags); - DPR_INIT(("unable to allocate tmp write buf")); - return (-ENOMEM); - } - - DGAP_UNLOCK(dgap_global_lock, flags); - return(0); -} - - -/* - * dgap_tty_register() - * - * Init the tty subsystem for this board. - */ -int dgap_tty_register(struct board_t *brd) -{ - int rc = 0; - - DPR_INIT(("tty_register start")); - - brd->SerialDriver = alloc_tty_driver(MAXPORTS); - - snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgap_%d_", brd->boardnum); - brd->SerialDriver->name = brd->SerialName; - brd->SerialDriver->name_base = 0; - brd->SerialDriver->major = 0; - brd->SerialDriver->minor_start = 0; - brd->SerialDriver->type = TTY_DRIVER_TYPE_SERIAL; - brd->SerialDriver->subtype = SERIAL_TYPE_NORMAL; - brd->SerialDriver->init_termios = DgapDefaultTermios; - brd->SerialDriver->driver_name = DRVSTR; - brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); - - /* The kernel wants space to store pointers to tty_structs */ - brd->SerialDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->SerialDriver->ttys) - return(-ENOMEM); - - /* - * Entry points for driver. Called by the kernel from - * tty_io.c and n_tty.c. - */ - tty_set_operations(brd->SerialDriver, &dgap_tty_ops); - - /* - * If we're doing transparent print, we have to do all of the above - * again, separately so we don't get the LD confused about what major - * we are when we get into the dgap_tty_open() routine. - */ - brd->PrintDriver = alloc_tty_driver(MAXPORTS); - - snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgap_%d_", brd->boardnum); - brd->PrintDriver->name = brd->PrintName; - brd->PrintDriver->name_base = 0; - brd->PrintDriver->major = 0; - brd->PrintDriver->minor_start = 0; - brd->PrintDriver->type = TTY_DRIVER_TYPE_SERIAL; - brd->PrintDriver->subtype = SERIAL_TYPE_NORMAL; - brd->PrintDriver->init_termios = DgapDefaultTermios; - brd->PrintDriver->driver_name = DRVSTR; - brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); - - /* The kernel wants space to store pointers to tty_structs */ - brd->PrintDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->PrintDriver->ttys) - return(-ENOMEM); - - /* - * Entry points for driver. Called by the kernel from - * tty_io.c and n_tty.c. - */ - tty_set_operations(brd->PrintDriver, &dgap_tty_ops); - - if (!brd->dgap_Major_Serial_Registered) { - /* Register tty devices */ - rc = tty_register_driver(brd->SerialDriver); - if (rc < 0) { - APR(("Can't register tty device (%d)\n", rc)); - return(rc); - } - brd->dgap_Major_Serial_Registered = TRUE; - dgap_BoardsByMajor[brd->SerialDriver->major] = brd; - brd->dgap_Serial_Major = brd->SerialDriver->major; - } - - if (!brd->dgap_Major_TransparentPrint_Registered) { - /* Register Transparent Print devices */ - rc = tty_register_driver(brd->PrintDriver); - if (rc < 0) { - APR(("Can't register Transparent Print device (%d)\n", rc)); - return(rc); - } - brd->dgap_Major_TransparentPrint_Registered = TRUE; - dgap_BoardsByMajor[brd->PrintDriver->major] = brd; - brd->dgap_TransparentPrint_Major = brd->PrintDriver->major; - } - - DPR_INIT(("DGAP REGISTER TTY: MAJORS: %d %d\n", brd->SerialDriver->major, - brd->PrintDriver->major)); - - return (rc); -} - - -/* - * dgap_tty_init() - * - * Init the tty subsystem. Called once per board after board has been - * downloaded and init'ed. - */ -int dgap_tty_init(struct board_t *brd) -{ - int i; - int tlw; - uint true_count = 0; - uchar *vaddr; - uchar modem = 0; - struct channel_t *ch; - struct bs_t *bs; - struct cm_t *cm; - - if (!brd) - return (-ENXIO); - - DPR_INIT(("dgap_tty_init start\n")); - - /* - * Initialize board structure elements. - */ - - vaddr = brd->re_map_membase; - true_count = readw((vaddr + NCHAN)); - - brd->nasync = dgap_config_get_number_of_ports(brd); - - if (!brd->nasync) { - brd->nasync = brd->maxports; - } - - if (brd->nasync > brd->maxports) { - brd->nasync = brd->maxports; - } - - if (true_count != brd->nasync) { - if ((brd->type == PPCM) && (true_count == 64)) { - APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n", - brd->name, brd->nasync, true_count)); - } - else if ((brd->type == PPCM) && (true_count == 0)) { - APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n", - brd->name, brd->nasync, true_count)); - } - else { - APR(("***WARNING**** %s configured for %d ports, has %d ports.\n", - brd->name, brd->nasync, true_count)); - } - - brd->nasync = true_count; - - /* If no ports, don't bother going any further */ - if (!brd->nasync) { - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - return(-ENXIO); - } - } - - /* - * 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]) { - brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_ATOMIC); - if (!brd->channels[i]) { - DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", - __FILE__, __LINE__)); - } - } - } - - ch = brd->channels[0]; - vaddr = brd->re_map_membase; - - bs = (struct bs_t *) ((ulong) vaddr + CHANBUF); - cm = (struct cm_t *) ((ulong) vaddr + CMDBUF); - - brd->bd_bs = bs; - - /* Set up channel variables */ - for (i = 0; i < brd->nasync; i++, ch = brd->channels[i], bs++) { - - if (!brd->channels[i]) - continue; - - DGAP_SPINLOCK_INIT(ch->ch_lock); - - /* Store all our magic numbers */ - ch->magic = DGAP_CHANNEL_MAGIC; - ch->ch_tun.magic = DGAP_UNIT_MAGIC; - ch->ch_tun.un_type = DGAP_SERIAL; - ch->ch_tun.un_ch = ch; - ch->ch_tun.un_dev = i; - - ch->ch_pun.magic = DGAP_UNIT_MAGIC; - ch->ch_pun.un_type = DGAP_PRINT; - ch->ch_pun.un_ch = ch; - ch->ch_pun.un_dev = i; - - ch->ch_vaddr = vaddr; - ch->ch_bs = bs; - ch->ch_cm = cm; - ch->ch_bd = brd; - ch->ch_portnum = i; - ch->ch_digi = dgap_digi_init; - - /* - * Set up digi dsr and dcd bits based on altpin flag. - */ - if (dgap_config_get_altpin(brd)) { - ch->ch_dsr = DM_CD; - ch->ch_cd = DM_DSR; - ch->ch_digi.digi_flags |= DIGI_ALTPIN; - } - else { - ch->ch_cd = DM_CD; - ch->ch_dsr = DM_DSR; - } - - ch->ch_taddr = vaddr + ((ch->ch_bs->tx_seg) << 4); - ch->ch_raddr = vaddr + ((ch->ch_bs->rx_seg) << 4); - ch->ch_tx_win = 0; - ch->ch_rx_win = 0; - ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1; - ch->ch_rsize = readw(&(ch->ch_bs->rx_max)) + 1; - ch->ch_tstart = 0; - ch->ch_rstart = 0; - - /* .25 second delay */ - ch->ch_close_delay = 250; - - /* - * Set queue water marks, interrupt mask, - * and general tty parameters. - */ - ch->ch_tlw = tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) : ch->ch_tsize / 2; - - dgap_cmdw(ch, STLOW, tlw, 0); - - dgap_cmdw(ch, SRLOW, ch->ch_rsize / 2, 0); - - dgap_cmdw(ch, SRHIGH, 7 * ch->ch_rsize / 8, 0); - - ch->ch_mistat = readb(&(ch->ch_bs->m_stat)); - - init_waitqueue_head(&ch->ch_flags_wait); - init_waitqueue_head(&ch->ch_tun.un_flags_wait); - init_waitqueue_head(&ch->ch_pun.un_flags_wait); - init_waitqueue_head(&ch->ch_sniff_wait); - - /* Turn on all modem interrupts for now */ - modem = (DM_CD | DM_DSR | DM_CTS | DM_RI); - writeb(modem, &(ch->ch_bs->m_int)); - - /* - * Set edelay to 0 if interrupts are turned on, - * otherwise set edelay to the usual 100. - */ - if (brd->intr_used) - writew(0, &(ch->ch_bs->edelay)); - else - writew(100, &(ch->ch_bs->edelay)); - - writeb(1, &(ch->ch_bs->idata)); - } - - - DPR_INIT(("dgap_tty_init finish\n")); - - return (0); -} - - -/* - * dgap_tty_post_uninit() - * - * UnInitialize any global tty related data. - */ -void dgap_tty_post_uninit(void) -{ - kfree(dgap_TmpWriteBuf); - dgap_TmpWriteBuf = NULL; -} - - -/* - * dgap_tty_uninit() - * - * Uninitialize the TTY portion of this driver. Free all memory and - * resources. - */ -void dgap_tty_uninit(struct board_t *brd) -{ - int i = 0; - - if (brd->dgap_Major_Serial_Registered) { - dgap_BoardsByMajor[brd->SerialDriver->major] = NULL; - brd->dgap_Serial_Major = 0; - for (i = 0; i < brd->nasync; i++) { - dgap_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); - tty_unregister_device(brd->SerialDriver, i); - } - tty_unregister_driver(brd->SerialDriver); - kfree(brd->SerialDriver->ttys); - brd->SerialDriver->ttys = NULL; - put_tty_driver(brd->SerialDriver); - brd->dgap_Major_Serial_Registered = FALSE; - } - - if (brd->dgap_Major_TransparentPrint_Registered) { - dgap_BoardsByMajor[brd->PrintDriver->major] = NULL; - brd->dgap_TransparentPrint_Major = 0; - for (i = 0; i < brd->nasync; i++) { - dgap_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); - tty_unregister_device(brd->PrintDriver, i); - } - tty_unregister_driver(brd->PrintDriver); - kfree(brd->PrintDriver->ttys); - brd->PrintDriver->ttys = NULL; - put_tty_driver(brd->PrintDriver); - brd->dgap_Major_TransparentPrint_Registered = FALSE; - } -} - - -#define TMPBUFLEN (1024) - -/* - * dgap_sniff - Dump data out to the "sniff" buffer if the - * proc sniff file is opened... - */ -static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int len) -{ - struct timeval tv; - int n; - int r; - int nbuf; - int i; - int tmpbuflen; - char tmpbuf[TMPBUFLEN]; - char *p = tmpbuf; - int too_much_data; - - /* Leave if sniff not open */ - if (!(ch->ch_sniff_flags & SNIFF_OPEN)) - return; - - do_gettimeofday(&tv); - - /* Create our header for data dump */ - p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text); - tmpbuflen = p - tmpbuf; - - do { - too_much_data = 0; - - for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) { - p += sprintf(p, "%02x ", *buf); - buf++; - tmpbuflen = p - tmpbuf; - } - - if (tmpbuflen < (TMPBUFLEN - 4)) { - if (i > 0) - p += sprintf(p - 1, "%s\n", ">"); - else - p += sprintf(p, "%s\n", ">"); - } else { - too_much_data = 1; - len -= i; - } - - nbuf = strlen(tmpbuf); - p = tmpbuf; - - /* - * Loop while data remains. - */ - while (nbuf > 0 && ch->ch_sniff_buf) { - /* - * Determine the amount of available space left in the - * buffer. If there's none, wait until some appears. - */ - n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & SNIFF_MASK; - - /* - * If there is no space left to write to in our sniff buffer, - * we have no choice but to drop the data. - * We *cannot* sleep here waiting for space, because this - * function was probably called by the interrupt/timer routines! - */ - if (n == 0) { - return; - } - - /* - * Copy as much data as will fit. - */ - - if (n > nbuf) - n = nbuf; - - r = SNIFF_MAX - ch->ch_sniff_in; - - if (r <= n) { - memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, r); - - n -= r; - ch->ch_sniff_in = 0; - p += r; - nbuf -= r; - } - - memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n); - - ch->ch_sniff_in += n; - p += n; - nbuf -= n; - - /* - * Wakeup any thread waiting for data - */ - if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) { - ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA; - wake_up_interruptible(&ch->ch_sniff_wait); - } - } - - /* - * If the user sent us too much data to push into our tmpbuf, - * we need to keep looping around on all the data. - */ - if (too_much_data) { - p = tmpbuf; - tmpbuflen = 0; - } - - } while (too_much_data); -} - - -/*======================================================================= - * - * dgap_input - Process received data. - * - * ch - Pointer to channel structure. - * - *=======================================================================*/ - -void dgap_input(struct channel_t *ch) -{ - struct board_t *bd; - struct bs_t *bs; - struct tty_struct *tp; - struct tty_ldisc *ld; - uint rmask; - uint head; - uint tail; - int data_len; - ulong lock_flags; - ulong lock_flags2; - int flip_len; - int len = 0; - int n = 0; - uchar *buf; - uchar tmpchar; - int s = 0; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - tp = ch->ch_tun.un_tty; - - bs = ch->ch_bs; - if (!bs) { - return; - } - - bd = ch->ch_bd; - if(!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_READ(("dgap_input start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - /* - * Figure the number of characters in the buffer. - * Exit immediately if none. - */ - - rmask = ch->ch_rsize - 1; - - head = readw(&(bs->rx_head)); - head &= rmask; - tail = readw(&(bs->rx_tail)); - tail &= rmask; - - data_len = (head - tail) & rmask; - - if (data_len == 0) { - writeb(1, &(bs->idata)); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - DPR_READ(("No data on port %d\n", ch->ch_portnum)); - return; - } - - /* - * If the device is not open, or CREAD is off, flush - * input data and return immediately. - */ - if ((bd->state != BOARD_READY) || !tp || (tp->magic != TTY_MAGIC) || - !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios.c_cflag & CREAD) || - (ch->ch_tun.un_flags & UN_CLOSING)) { - - DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); - DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n", - tp, tp ? tp->magic : 0, TTY_MAGIC, ch->ch_tun.un_flags)); - writew(head, &(bs->rx_tail)); - writeb(1, &(bs->idata)); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return; - } - - /* - * If we are throttled, simply don't read any data. - */ - if (ch->ch_flags & CH_RXBLOCK) { - writeb(1, &(bs->idata)); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - DPR_READ(("Port %d throttled, not reading any data. head: %x tail: %x\n", - ch->ch_portnum, head, tail)); - return; - } - - /* - * Ignore oruns. - */ - tmpchar = readb(&(bs->orun)); - if (tmpchar) { - ch->ch_err_overrun++; - writeb(0, &(bs->orun)); - } - - DPR_READ(("dgap_input start 2\n")); - - /* Decide how much data we can send into the tty layer */ - flip_len = TTY_FLIPBUF_SIZE; - - /* Chop down the length, if needed */ - len = min(data_len, flip_len); - len = min(len, (N_TTY_BUF_SIZE - 1)); - - 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 - * have any space to put the data right now. - */ - if (!ld) { - len = 0; - } else { - /* - * If ld doesn't have a pointer to a receive_buf function, - * flush the data, then act like the ld doesn't have any - * space to put the data right now. - */ - if (!ld->ops->receive_buf) { - writew(head, &(bs->rx_tail)); - len = 0; - } - } - - if (len <= 0) { - writeb(1, &(bs->idata)); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - DPR_READ(("dgap_input 1 - finish\n")); - if (ld) - tty_ldisc_deref(ld); - return; - } - - buf = ch->ch_bd->flipbuf; - n = len; - - /* - * n now contains the most amount of data we can copy, - * bounded either by our buffer size or the amount - * of data the card actually has pending... - */ - while (n) { - - s = ((head >= tail) ? head : ch->ch_rsize) - tail; - s = min(s, n); - - if (s <= 0) - break; - - memcpy_fromio(buf, (char *) ch->ch_raddr + tail, s); - dgap_sniff_nowait_nolock(ch, "USER READ", buf, s); - - tail += s; - buf += s; - - n -= s; - /* Flip queue if needed */ - tail &= rmask; - } - - writew(tail, &(bs->rx_tail)); - writeb(1, &(bs->idata)); - ch->ch_rxcount += len; - - /* - * If we are completely raw, we don't need to go through a lot - * of the tty layers that exist. - * In this case, we take the shortest and fastest route we - * can to relay the data to the user. - * - * On the other hand, if we are not raw, we need to go through - * the tty layer, which has its API more well defined. - */ - if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { - dgap_parity_scan(ch, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, &len); - - len = tty_buffer_request_room(tp->port, len); - tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf, - ch->ch_bd->flipflagbuf, len); - } - else { - len = tty_buffer_request_room(tp->port, len); - tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len); - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp->port); - - if (ld) - tty_ldisc_deref(ld); - - DPR_READ(("dgap_input - finish\n")); -} - - -/************************************************************************ - * Determines when CARRIER changes state and takes appropriate - * action. - ************************************************************************/ -void dgap_carrier(struct channel_t *ch) -{ - struct board_t *bd; - - int virt_carrier = 0; - int phys_carrier = 0; - - DPR_CARR(("dgap_carrier called...\n")); - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - /* Make sure altpin is always set correctly */ - if (ch->ch_digi.digi_flags & DIGI_ALTPIN) { - ch->ch_dsr = DM_CD; - ch->ch_cd = DM_DSR; - } - else { - ch->ch_dsr = DM_DSR; - ch->ch_cd = DM_CD; - } - - if (ch->ch_mistat & D_CD(ch)) { - DPR_CARR(("mistat: %x D_CD: %x\n", ch->ch_mistat, D_CD(ch))); - phys_carrier = 1; - } - - if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) { - virt_carrier = 1; - } - - if (ch->ch_c_cflag & CLOCAL) { - virt_carrier = 1; - } - - - DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); - - /* - * Test for a VIRTUAL carrier transition to HIGH. - */ - if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { - - /* - * When carrier rises, wake any threads waiting - * for carrier in the open routine. - */ - - DPR_CARR(("carrier: virt DCD rose\n")); - - if (waitqueue_active(&(ch->ch_flags_wait))) - wake_up_interruptible(&ch->ch_flags_wait); - } - - /* - * Test for a PHYSICAL carrier transition to HIGH. - */ - if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { - - /* - * When carrier rises, wake any threads waiting - * for carrier in the open routine. - */ - - DPR_CARR(("carrier: physical DCD rose\n")); - - if (waitqueue_active(&(ch->ch_flags_wait))) - wake_up_interruptible(&ch->ch_flags_wait); - } - - /* - * Test for a PHYSICAL transition to low, so long as we aren't - * currently ignoring physical transitions (which is what "virtual - * carrier" indicates). - * - * The transition of the virtual carrier to low really doesn't - * matter... it really only means "ignore carrier state", not - * "make pretend that carrier is there". - */ - if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && - (phys_carrier == 0)) - { - - /* - * When carrier drops: - * - * Drop carrier on all open units. - * - * Flush queues, waking up any task waiting in the - * line discipline. - * - * Send a hangup to the control terminal. - * - * Enable all select calls. - */ - if (waitqueue_active(&(ch->ch_flags_wait))) - wake_up_interruptible(&ch->ch_flags_wait); - - if (ch->ch_tun.un_open_count > 0) { - DPR_CARR(("Sending tty hangup\n")); - tty_hangup(ch->ch_tun.un_tty); - } - - if (ch->ch_pun.un_open_count > 0) { - DPR_CARR(("Sending pr hangup\n")); - tty_hangup(ch->ch_pun.un_tty); - } - } - - /* - * Make sure that our cached values reflect the current reality. - */ - if (virt_carrier == 1) - ch->ch_flags |= CH_FCAR; - else - ch->ch_flags &= ~CH_FCAR; - - if (phys_carrier == 1) - ch->ch_flags |= CH_CD; - else - ch->ch_flags &= ~CH_CD; -} - - -/************************************************************************ - * - * TTY Entry points and helper functions - * - ************************************************************************/ - -/* - * dgap_tty_open() - * - */ -static int dgap_tty_open(struct tty_struct *tty, struct file *file) -{ - struct board_t *brd; - struct channel_t *ch; - struct un_t *un; - struct bs_t *bs; - uint major = 0; - uint minor = 0; - int rc = 0; - ulong lock_flags; - ulong lock_flags2; - u16 head; - - rc = 0; - - major = MAJOR(tty_devnum(tty)); - minor = MINOR(tty_devnum(tty)); - - if (major > 255) { - return -ENXIO; - } - - /* Get board pointer from our array of majors we have allocated */ - brd = dgap_BoardsByMajor[major]; - if (!brd) { - return -ENXIO; - } - - /* - * If board is not yet up to a state of READY, go to - * sleep waiting for it to happen or they cancel the open. - */ - rc = wait_event_interruptible(brd->state_wait, - (brd->state & BOARD_READY)); - - if (rc) { - return rc; - } - - DGAP_LOCK(brd->bd_lock, lock_flags); - - /* The wait above should guarantee this cannot happen */ - if (brd->state != BOARD_READY) { - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return -ENXIO; - } - - /* If opened device is greater than our number of ports, bail. */ - if (MINOR(tty_devnum(tty)) > brd->nasync) { - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return -ENXIO; - } - - ch = brd->channels[minor]; - if (!ch) { - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return -ENXIO; - } - - /* Grab channel lock */ - DGAP_LOCK(ch->ch_lock, lock_flags2); - - /* Figure out our type */ - if (major == brd->dgap_Serial_Major) { - un = &brd->channels[minor]->ch_tun; - un->un_type = DGAP_SERIAL; - } - else if (major == brd->dgap_TransparentPrint_Major) { - un = &brd->channels[minor]->ch_pun; - un->un_type = DGAP_PRINT; - } - else { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(brd->bd_lock, lock_flags); - DPR_OPEN(("%d Unknown TYPE!\n", __LINE__)); - return -ENXIO; - } - - /* Store our unit into driver_data, so we always have it available. */ - tty->driver_data = un; - - DPR_OPEN(("Open called. MAJOR: %d MINOR:%d unit: %p NAME: %s\n", - MAJOR(tty_devnum(tty)), MINOR(tty_devnum(tty)), un, brd->name)); - - /* - * Error if channel info pointer is NULL. - */ - bs = ch->ch_bs; - if (!bs) { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(brd->bd_lock, lock_flags); - DPR_OPEN(("%d BS is 0!\n", __LINE__)); - return -ENXIO; - } - - DPR_OPEN(("%d: tflag=%x pflag=%x\n", __LINE__, ch->ch_tun.un_flags, ch->ch_pun.un_flags)); - - /* - * Initialize tty's - */ - if (!(un->un_flags & UN_ISOPEN)) { - /* Store important variables. */ - un->un_tty = tty; - - /* Maybe do something here to the TTY struct as well? */ - } - - /* - * Initialize if neither terminal or printer is open. - */ - if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { - - DPR_OPEN(("dgap_open: initializing channel in open...\n")); - - ch->ch_mforce = 0; - ch->ch_mval = 0; - - /* - * Flush input queue. - */ - head = readw(&(bs->rx_head)); - writew(head, &(bs->rx_tail)); - - ch->ch_flags = 0; - ch->pscan_state = 0; - ch->pscan_savechar = 0; - - ch->ch_c_cflag = tty->termios.c_cflag; - ch->ch_c_iflag = tty->termios.c_iflag; - ch->ch_c_oflag = tty->termios.c_oflag; - ch->ch_c_lflag = tty->termios.c_lflag; - ch->ch_startc = tty->termios.c_cc[VSTART]; - ch->ch_stopc = tty->termios.c_cc[VSTOP]; - - /* TODO: flush our TTY struct here? */ - } - - dgap_carrier(ch); - /* - * Run param in case we changed anything - */ - dgap_param(tty); - - /* - * follow protocol for opening port - */ - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(brd->bd_lock, lock_flags); - - rc = dgap_block_til_ready(tty, file, ch); - - if (!un->un_tty) { - return -ENODEV; - } - - if (rc) { - DPR_OPEN(("dgap_tty_open returning after dgap_block_til_ready " - "with %d\n", rc)); - } - - /* No going back now, increment our unit and channel counters */ - DGAP_LOCK(ch->ch_lock, lock_flags); - ch->ch_open_count++; - un->un_open_count++; - un->un_flags |= (UN_ISOPEN); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_OPEN(("dgap_tty_open finished\n")); - return (rc); -} - - -/* - * dgap_block_til_ready() - * - * Wait for DCD, if needed. - */ -static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) -{ - int retval = 0; - struct un_t *un = NULL; - ulong lock_flags; - uint old_flags = 0; - int sleep_on_un_flags = 0; - - if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGAP_CHANNEL_MAGIC) { - return (-ENXIO); - } - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) { - return (-ENXIO); - } - - DPR_OPEN(("dgap_block_til_ready - before block.\n")); - - DGAP_LOCK(ch->ch_lock, lock_flags); - - ch->ch_wopen++; - - /* Loop forever */ - while (1) { - - sleep_on_un_flags = 0; - - /* - * If board has failed somehow during our sleep, bail with error. - */ - if (ch->ch_bd->state == BOARD_FAILED) { - retval = -ENXIO; - break; - } - - /* If tty was hung up, break out of loop and set error. */ - if (tty_hung_up_p(file)) { - retval = -EAGAIN; - break; - } - - /* - * If either unit is in the middle of the fragile part of close, - * we just cannot touch the channel safely. - * Go back to sleep, knowing that when the channel can be - * touched safely, the close routine will signal the - * ch_wait_flags to wake us back up. - */ - if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { - - /* - * Our conditions to leave cleanly and happily: - * 1) NONBLOCKING on the tty is set. - * 2) CLOCAL is set. - * 3) DCD (fake or real) is active. - */ - - if (file->f_flags & O_NONBLOCK) { - break; - } - - if (tty->flags & (1 << TTY_IO_ERROR)) { - break; - } - - if (ch->ch_flags & CH_CD) { - DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); - break; - } - - if (ch->ch_flags & CH_FCAR) { - DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); - break; - } - } - else { - sleep_on_un_flags = 1; - } - - /* - * If there is a signal pending, the user probably - * interrupted (ctrl-c) us. - * Leave loop with error set. - */ - if (signal_pending(current)) { - DPR_OPEN(("%d: signal pending...\n", __LINE__)); - retval = -ERESTARTSYS; - break; - } - - DPR_OPEN(("dgap_block_til_ready - blocking.\n")); - - /* - * Store the flags before we let go of channel lock - */ - if (sleep_on_un_flags) - old_flags = ch->ch_tun.un_flags | ch->ch_pun.un_flags; - else - old_flags = ch->ch_flags; - - /* - * Let go of channel lock before calling schedule. - * Our poller will get any FEP events and wake us up when DCD - * eventually goes active. - */ - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_OPEN(("Going to sleep on %s flags...\n", - (sleep_on_un_flags ? "un" : "ch"))); - - /* - * Wait for something in the flags to change from the current value. - */ - if (sleep_on_un_flags) { - retval = wait_event_interruptible(un->un_flags_wait, - (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); - } - else { - retval = wait_event_interruptible(ch->ch_flags_wait, - (old_flags != ch->ch_flags)); - } - - DPR_OPEN(("After sleep... retval: %x\n", retval)); - - /* - * We got woken up for some reason. - * Before looping around, grab our channel lock. - */ - DGAP_LOCK(ch->ch_lock, lock_flags); - } - - ch->ch_wopen--; - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_OPEN(("dgap_block_til_ready - after blocking.\n")); - - if (retval) { - DPR_OPEN(("dgap_block_til_ready - done. error. retval: %x\n", retval)); - return(retval); - } - - DPR_OPEN(("dgap_block_til_ready - done no error. jiffies: %lu\n", jiffies)); - - return(0); -} - - -/* - * dgap_tty_hangup() - * - * Hangup the port. Like a close, but don't wait for output to drain. - */ -static void dgap_tty_hangup(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_CLOSE(("dgap_hangup called. ch->ch_open_count: %d un->un_open_count: %d\n", - ch->ch_open_count, un->un_open_count)); - - /* flush the transmit queues */ - dgap_tty_flush_buffer(tty); - - DPR_CLOSE(("dgap_hangup finished. ch->ch_open_count: %d un->un_open_count: %d\n", - ch->ch_open_count, un->un_open_count)); -} - - - -/* - * dgap_tty_close() - * - */ -static void dgap_tty_close(struct tty_struct *tty, struct file *file) -{ - struct ktermios *ts; - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - int rc = 0; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - ts = &tty->termios; - - DPR_CLOSE(("Close called\n")); - - DGAP_LOCK(ch->ch_lock, lock_flags); - - /* - * Determine if this is the last close or not - and if we agree about - * which type of close it is with the Line Discipline - */ - if ((tty->count == 1) && (un->un_open_count != 1)) { - /* - * Uh, oh. tty->count is 1, which means that the tty - * structure will be freed. un_open_count should always - * be one in these conditions. If it's greater than - * one, we've got real problems, since it means the - * serial port won't be shutdown. - */ - APR(("tty->count is 1, un open count is %d\n", un->un_open_count)); - un->un_open_count = 1; - } - - if (--un->un_open_count < 0) { - APR(("bad serial port open count of %d\n", un->un_open_count)); - un->un_open_count = 0; - } - - ch->ch_open_count--; - - if (ch->ch_open_count && un->un_open_count) { - DPR_CLOSE(("dgap_tty_close: not last close ch: %d un:%d\n", - ch->ch_open_count, un->un_open_count)); - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - return; - } - - /* OK, its the last close on the unit */ - DPR_CLOSE(("dgap_tty_close - last close on unit procedures\n")); - - un->un_flags |= UN_CLOSING; - - tty->closing = 1; - - /* - * Only officially close channel if count is 0 and - * DIGI_PRINTER bit is not set. - */ - if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { - - ch->ch_flags &= ~(CH_RXBLOCK); - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - /* wait for output to drain */ - /* This will also return if we take an interrupt */ - - DPR_CLOSE(("Calling wait_for_drain\n")); - rc = dgap_wait_for_drain(tty); - DPR_CLOSE(("After calling wait_for_drain\n")); - - if (rc) { - DPR_BASIC(("dgap_tty_close - bad return: %d ", rc)); - } - - dgap_tty_flush_buffer(tty); - tty_ldisc_flush(tty); - - DGAP_LOCK(ch->ch_lock, lock_flags); - - tty->closing = 0; - - /* - * If we have HUPCL set, lower DTR and RTS - */ - if (ch->ch_c_cflag & HUPCL ) { - DPR_CLOSE(("Close. HUPCL set, dropping DTR/RTS\n")); - ch->ch_mostat &= ~(D_RTS(ch)|D_DTR(ch)); - dgap_cmdb( ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0 ); - - /* - * Go to sleep to ensure RTS/DTR - * have been dropped for modems to see it. - */ - if (ch->ch_close_delay) { - DPR_CLOSE(("Close. Sleeping for RTS/DTR drop\n")); - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - dgap_ms_sleep(ch->ch_close_delay); - DGAP_LOCK(ch->ch_lock, lock_flags); - - DPR_CLOSE(("Close. After sleeping for RTS/DTR drop\n")); - } - } - - ch->pscan_state = 0; - ch->pscan_savechar = 0; - ch->ch_baud_info = 0; - - } - - /* - * turn off print device when closing print device. - */ - if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON) ) { - dgap_wmove(ch, ch->ch_digi.digi_offstr, - (int) ch->ch_digi.digi_offlen); - ch->ch_flags &= ~CH_PRON; - } - - un->un_tty = NULL; - un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); - tty->driver_data = NULL; - - DPR_CLOSE(("Close. Doing wakeups\n")); - wake_up_interruptible(&ch->ch_flags_wait); - wake_up_interruptible(&un->un_flags_wait); - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_BASIC(("dgap_tty_close - complete\n")); -} - - -/* - * dgap_tty_chars_in_buffer() - * - * Return number of characters that have not been transmitted yet. - * - * This routine is used by the line discipline to determine if there - * is data waiting to be transmitted/drained/flushed or not. - */ -static int dgap_tty_chars_in_buffer(struct tty_struct *tty) -{ - struct board_t *bd = NULL; - struct channel_t *ch = NULL; - struct un_t *un = NULL; - struct bs_t *bs = NULL; - uchar tbusy; - uint chars = 0; - u16 thead, ttail, tmask, chead, ctail; - ulong lock_flags = 0; - ulong lock_flags2 = 0; - - if (tty == NULL) - return(0); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - - bs = ch->ch_bs; - if (!bs) - return (0); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - tmask = (ch->ch_tsize - 1); - - /* Get Transmit queue pointers */ - thead = readw(&(bs->tx_head)) & tmask; - ttail = readw(&(bs->tx_tail)) & tmask; - - /* Get tbusy flag */ - tbusy = readb(&(bs->tbusy)); - - /* Get Command queue pointers */ - chead = readw(&(ch->ch_cm->cm_head)); - ctail = readw(&(ch->ch_cm->cm_tail)); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - /* - * The only way we know for sure if there is no pending - * data left to be transferred, is if: - * 1) Transmit head and tail are equal (empty). - * 2) Command queue head and tail are equal (empty). - * 3) The "TBUSY" flag is 0. (Transmitter not busy). - */ - - if ((ttail == thead) && (tbusy == 0) && (chead == ctail)) { - chars = 0; - } - else { - if (thead >= ttail) - chars = thead - ttail; - else - chars = thead - ttail + ch->ch_tsize; - /* - * Fudge factor here. - * If chars is zero, we know that the command queue had - * something in it or tbusy was set. Because we cannot - * be sure if there is still some data to be transmitted, - * lets lie, and tell ld we have 1 byte left. - */ - if (chars == 0) { - /* - * If TBUSY is still set, and our tx buffers are empty, - * force the firmware to send me another wakeup after - * TBUSY has been cleared. - */ - if (tbusy != 0) { - DGAP_LOCK(ch->ch_lock, lock_flags); - un->un_flags |= UN_EMPTY; - writeb(1, &(bs->iempty)); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - } - chars = 1; - } - } - - DPR_WRITE(("dgap_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d tsize: %d)\n", - ch->ch_portnum, chars, thead, ttail, ch->ch_tsize)); - return(chars); -} - - -static int dgap_wait_for_drain(struct tty_struct *tty) -{ - struct channel_t *ch; - struct un_t *un; - struct bs_t *bs; - int ret = -EIO; - uint count = 1; - ulong lock_flags = 0; - - if (!tty || tty->magic != TTY_MAGIC) - return ret; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; - - bs = ch->ch_bs; - if (!bs) - return ret; - - ret = 0; - - DPR_DRAIN(("dgap_wait_for_drain start\n")); - - /* Loop until data is drained */ - while (count != 0) { - - count = dgap_tty_chars_in_buffer(tty); - - if (count == 0) - break; - - /* Set flag waiting for drain */ - DGAP_LOCK(ch->ch_lock, lock_flags); - un->un_flags |= UN_EMPTY; - writeb(1, &(bs->iempty)); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - /* Go to sleep till we get woken up */ - ret = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0)); - /* If ret is non-zero, user ctrl-c'ed us */ - if (ret) { - break; - } - } - - DGAP_LOCK(ch->ch_lock, lock_flags); - un->un_flags &= ~(UN_EMPTY); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_DRAIN(("dgap_wait_for_drain finish\n")); - return (ret); -} - - -/* - * dgap_maxcps_room - * - * Reduces bytes_available to the max number of characters - * that can be sent currently given the maxcps value, and - * returns the new bytes_available. This only affects printer - * output. - */ -static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) -{ - struct channel_t *ch = NULL; - struct un_t *un = NULL; - - if (tty == NULL) - return (bytes_available); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (bytes_available); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (bytes_available); - - /* - * If its not the Transparent print device, return - * the full data amount. - */ - if (un->un_type != DGAP_PRINT) - return (bytes_available); - - if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0 ) { - int cps_limit = 0; - unsigned long current_time = jiffies; - unsigned long buffer_time = current_time + - (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps; - - if (ch->ch_cpstime < current_time) { - /* buffer is empty */ - ch->ch_cpstime = current_time; /* reset ch_cpstime */ - cps_limit = ch->ch_digi.digi_bufsize; - } - else if (ch->ch_cpstime < buffer_time) { - /* still room in the buffer */ - cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; - } - else { - /* no room in the buffer */ - cps_limit = 0; - } - - bytes_available = min(cps_limit, bytes_available); - } - - return (bytes_available); -} - - -static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) -{ - struct channel_t *ch = NULL; - struct bs_t *bs = NULL; - - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - bs = ch->ch_bs; - if (!bs) - return; - - if ((event & UN_LOW) != 0) { - if ((un->un_flags & UN_LOW) == 0) { - un->un_flags |= UN_LOW; - writeb(1, &(bs->ilow)); - } - } - if ((event & UN_LOW) != 0) { - if ((un->un_flags & UN_EMPTY) == 0) { - un->un_flags |= UN_EMPTY; - writeb(1, &(bs->iempty)); - } - } -} - - -/* - * dgap_tty_write_room() - * - * Return space available in Tx buffer - */ -static int dgap_tty_write_room(struct tty_struct *tty) -{ - struct channel_t *ch = NULL; - struct un_t *un = NULL; - struct bs_t *bs = NULL; - u16 head, tail, tmask; - int ret = 0; - ulong lock_flags = 0; - - if (tty == NULL || dgap_TmpWriteBuf == NULL) - return(0); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - - bs = ch->ch_bs; - if (!bs) - return (0); - - DGAP_LOCK(ch->ch_lock, lock_flags); - - tmask = ch->ch_tsize - 1; - head = readw(&(bs->tx_head)) & tmask; - tail = readw(&(bs->tx_tail)) & tmask; - - if ((ret = tail - head - 1) < 0) - ret += ch->ch_tsize; - - /* Limit printer to maxcps */ - ret = dgap_maxcps_room(tty, ret); - - /* - * If we are printer device, leave space for - * possibly both the on and off strings. - */ - if (un->un_type == DGAP_PRINT) { - if (!(ch->ch_flags & CH_PRON)) - ret -= ch->ch_digi.digi_onlen; - ret -= ch->ch_digi.digi_offlen; - } - else { - if (ch->ch_flags & CH_PRON) - ret -= ch->ch_digi.digi_offlen; - } - - if (ret < 0) - ret = 0; - - /* - * Schedule FEP to wake us up if needed. - * - * TODO: This might be overkill... - * Do we really need to schedule callbacks from the FEP - * in every case? Can we get smarter based on ret? - */ - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_WRITE(("dgap_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); - - return(ret); -} - - -/* - * dgap_tty_put_char() - * - * Put a character into ch->ch_buf - * - * - used by the line discipline for OPOST processing - */ -static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c) -{ - /* - * Simply call tty_write. - */ - DPR_WRITE(("dgap_tty_put_char called\n")); - dgap_tty_write(tty, &c, 1); - return 1; -} - - -/* - * dgap_tty_write() - * - * Take data from the user or kernel and send it out to the FEP. - * In here exists all the Transparent Print magic as well. - */ -static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) -{ - struct channel_t *ch = NULL; - struct un_t *un = NULL; - struct bs_t *bs = NULL; - char *vaddr = NULL; - u16 head, tail, tmask, remain; - int bufcount = 0, n = 0; - int orig_count = 0; - ulong lock_flags; - int from_user = 0; - - if (tty == NULL || dgap_TmpWriteBuf == NULL) - return(0); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return(0); - - bs = ch->ch_bs; - if (!bs) - return(0); - - if (!count) - return(0); - - DPR_WRITE(("dgap_tty_write: Port: %x tty=%p user=%d len=%d\n", - ch->ch_portnum, tty, from_user, count)); - - /* - * Store original amount of characters passed in. - * This helps to figure out if we should ask the FEP - * to send us an event when it has more space available. - */ - orig_count = count; - - DGAP_LOCK(ch->ch_lock, lock_flags); - - /* Get our space available for the channel from the board */ - tmask = ch->ch_tsize - 1; - head = readw(&(bs->tx_head)) & tmask; - tail = readw(&(bs->tx_tail)) & tmask; - - if ((bufcount = tail - head - 1) < 0) - bufcount += ch->ch_tsize; - - DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n", - __LINE__, bufcount, count, tail, head, tmask)); - - /* - * Limit printer output to maxcps overall, with bursts allowed - * up to bufsize characters. - */ - bufcount = dgap_maxcps_room(tty, bufcount); - - /* - * Take minimum of what the user wants to send, and the - * space available in the FEP buffer. - */ - count = min(count, bufcount); - - /* - * Bail if no space left. - */ - if (count <= 0) { - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - return(0); - } - - /* - * Output the printer ON string, if we are in terminal mode, but - * need to be in printer mode. - */ - if ((un->un_type == DGAP_PRINT) && !(ch->ch_flags & CH_PRON)) { - dgap_wmove(ch, ch->ch_digi.digi_onstr, - (int) ch->ch_digi.digi_onlen); - head = readw(&(bs->tx_head)) & tmask; - ch->ch_flags |= CH_PRON; - } - - /* - * On the other hand, output the printer OFF string, if we are - * currently in printer mode, but need to output to the terminal. - */ - if ((un->un_type != DGAP_PRINT) && (ch->ch_flags & CH_PRON)) { - dgap_wmove(ch, ch->ch_digi.digi_offstr, - (int) ch->ch_digi.digi_offlen); - head = readw(&(bs->tx_head)) & tmask; - ch->ch_flags &= ~CH_PRON; - } - - /* - * If there is nothing left to copy, or I can't handle any more data, leave. - */ - if (count <= 0) { - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - return(0); - } - - if (from_user) { - - count = min(count, WRITEBUFLEN); - - DGAP_UNLOCK(ch->ch_lock, 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(&dgap_TmpWriteSem)) { - return (-EINTR); - } - - if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { - up(&dgap_TmpWriteSem); - printk("Write: Copy from user failed!\n"); - return -EFAULT; - } - - DGAP_LOCK(ch->ch_lock, lock_flags); - - buf = dgap_TmpWriteBuf; - } - - n = count; - - /* - * If the write wraps over the top of the circular buffer, - * move the portion up to the wrap point, and reset the - * pointers to the bottom. - */ - remain = ch->ch_tstart + ch->ch_tsize - head; - - if (n >= remain) { - n -= remain; - vaddr = ch->ch_taddr + head; - - memcpy_toio(vaddr, (uchar *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, remain); - - head = ch->ch_tstart; - buf += remain; - } - - if (n > 0) { - - /* - * Move rest of data. - */ - vaddr = ch->ch_taddr + head; - remain = n; - - memcpy_toio(vaddr, (uchar *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, remain); - - head += remain; - - } - - if (count) { - ch->ch_txcount += count; - head &= tmask; - writew(head, &(bs->tx_head)); - } - - - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); - - /* - * If this is the print device, and the - * printer is still on, we need to turn it - * off before going idle. If the buffer is - * non-empty, wait until it goes empty. - * Otherwise turn it off right now. - */ - if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON)) { - tail = readw(&(bs->tx_tail)) & tmask; - - if (tail != head) { - un->un_flags |= UN_EMPTY; - writeb(1, &(bs->iempty)); - } - else { - dgap_wmove(ch, ch->ch_digi.digi_offstr, - (int) ch->ch_digi.digi_offlen); - head = readw(&(bs->tx_head)) & tmask; - ch->ch_flags &= ~CH_PRON; - } - } - - /* Update printer buffer empty time. */ - if ((un->un_type == DGAP_PRINT) && (ch->ch_digi.digi_maxcps > 0) - && (ch->ch_digi.digi_bufsize > 0)) { - ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; - } - - if (from_user) { - DGAP_UNLOCK(ch->ch_lock, lock_flags); - up(&dgap_TmpWriteSem); - } - else { - DGAP_UNLOCK(ch->ch_lock, lock_flags); - } - - DPR_WRITE(("Write finished - Write %d bytes of %d.\n", count, orig_count)); - - return (count); -} - - - -/* - * Return modem signals to ld. - */ -static int dgap_tty_tiocmget(struct tty_struct *tty) -{ - struct channel_t *ch; - struct un_t *un; - int result = -EIO; - uchar mstat = 0; - ulong lock_flags; - - if (!tty || tty->magic != TTY_MAGIC) - return result; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return result; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return result; - - DPR_IOCTL(("dgap_tty_tiocmget start\n")); - - DGAP_LOCK(ch->ch_lock, lock_flags); - - mstat = readb(&(ch->ch_bs->m_stat)); - /* Append any outbound signals that might be pending... */ - mstat |= ch->ch_mostat; - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - result = 0; - - if (mstat & D_DTR(ch)) - result |= TIOCM_DTR; - if (mstat & D_RTS(ch)) - result |= TIOCM_RTS; - if (mstat & D_CTS(ch)) - result |= TIOCM_CTS; - if (mstat & D_DSR(ch)) - result |= TIOCM_DSR; - if (mstat & D_RI(ch)) - result |= TIOCM_RI; - if (mstat & D_CD(ch)) - result |= TIOCM_CD; - - DPR_IOCTL(("dgap_tty_tiocmget finish\n")); - - return result; -} - - -/* - * dgap_tty_tiocmset() - * - * Set modem signals, called by ld. - */ - -static int dgap_tty_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int ret = -EIO; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return ret; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return ret; - - DPR_IOCTL(("dgap_tty_tiocmset start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - if (set & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval |= D_RTS(ch); - } - - if (set & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval |= D_DTR(ch); - } - - if (clear & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval &= ~(D_RTS(ch)); - } - - if (clear & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval &= ~(D_DTR(ch)); - } - - dgap_param(tty); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_tiocmset finish\n")); - - return (0); -} - - - -/* - * dgap_tty_send_break() - * - * Send a Break, called by ld. - */ -static int dgap_tty_send_break(struct tty_struct *tty, int msec) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int ret = -EIO; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return ret; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return ret; - - switch (msec) { - case -1: - msec = 0xFFFF; - break; - case 0: - msec = 1; - break; - default: - msec /= 10; - break; - } - - DPR_IOCTL(("dgap_tty_send_break start 1. %lx\n", jiffies)); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); -#if 0 - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); -#endif - dgap_cmdw(ch, SBREAK, (u16) msec, 0); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_send_break finish\n")); - - return (0); -} - - - - -/* - * dgap_tty_wait_until_sent() - * - * wait until data has been transmitted, called by ld. - */ -static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout) -{ - int rc; - rc = dgap_wait_for_drain(tty); - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return; - } - return; -} - - - -/* - * dgap_send_xchar() - * - * send a high priority character, called by ld. - */ -static void dgap_tty_send_xchar(struct tty_struct *tty, char c) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_send_xchar start 1. %lx\n", jiffies)); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - /* - * This is technically what we should do. - * However, the NIST tests specifically want - * to see each XON or XOFF character that it - * sends, so lets just send each character - * by hand... - */ -#if 0 - if (c == STOP_CHAR(tty)) { - dgap_cmdw(ch, RPAUSE, 0, 0); - } - else if (c == START_CHAR(tty)) { - dgap_cmdw(ch, RRESUME, 0, 0); - } - else { - dgap_wmove(ch, &c, 1); - } -#else - dgap_wmove(ch, &c, 1); -#endif - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_send_xchar finish\n")); - - return; -} - - - - -/* - * Return modem signals to ld. - */ -static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) -{ - int result = 0; - uchar mstat = 0; - ulong lock_flags; - int rc = 0; - - DPR_IOCTL(("dgap_get_modem_info start\n")); - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return(-ENXIO); - - DGAP_LOCK(ch->ch_lock, lock_flags); - - mstat = readb(&(ch->ch_bs->m_stat)); - /* Append any outbound signals that might be pending... */ - mstat |= ch->ch_mostat; - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - result = 0; - - if (mstat & D_DTR(ch)) - result |= TIOCM_DTR; - if (mstat & D_RTS(ch)) - result |= TIOCM_RTS; - if (mstat & D_CTS(ch)) - result |= TIOCM_CTS; - if (mstat & D_DSR(ch)) - result |= TIOCM_DSR; - if (mstat & D_RI(ch)) - result |= TIOCM_RI; - if (mstat & D_CD(ch)) - result |= TIOCM_CD; - - rc = put_user(result, value); - - DPR_IOCTL(("dgap_get_modem_info finish\n")); - return(rc); -} - - -/* - * dgap_set_modem_info() - * - * Set modem signals, called by ld. - */ -static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int ret = -ENXIO; - unsigned int arg = 0; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return ret; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return ret; - - DPR_IOCTL(("dgap_set_modem_info() start\n")); - - ret = get_user(arg, value); - if (ret) { - DPR_IOCTL(("dgap_set_modem_info %d ret: %x. finished.\n", __LINE__, ret)); - return(ret); - } - - DPR_IOCTL(("dgap_set_modem_info: command: %x arg: %x\n", command, arg)); - - switch (command) { - case TIOCMBIS: - if (arg & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval |= D_RTS(ch); - } - - if (arg & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval |= D_DTR(ch); - } - - break; - - case TIOCMBIC: - if (arg & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval &= ~(D_RTS(ch)); - } - - if (arg & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval &= ~(D_DTR(ch)); - } - - break; - - case TIOCMSET: - ch->ch_mforce = D_DTR(ch)|D_RTS(ch); - - if (arg & TIOCM_RTS) { - ch->ch_mval |= D_RTS(ch); - } - else { - ch->ch_mval &= ~(D_RTS(ch)); - } - - if (arg & TIOCM_DTR) { - ch->ch_mval |= (D_DTR(ch)); - } - else { - ch->ch_mval &= ~(D_DTR(ch)); - } - - break; - - default: - return(-EINVAL); - } - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - dgap_param(tty); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_set_modem_info finish\n")); - - return (0); -} - - -/* - * dgap_tty_digigeta() - * - * Ioctl to get the information for ditty. - * - * - * - */ -static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) -{ - struct channel_t *ch; - struct un_t *un; - struct digi_t tmp; - ulong lock_flags; - - if (!retinfo) - return (-EFAULT); - - if (!tty || tty->magic != TTY_MAGIC) - return (-EFAULT); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-EFAULT); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-EFAULT); - - memset(&tmp, 0, sizeof(tmp)); - - DGAP_LOCK(ch->ch_lock, lock_flags); - memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return (-EFAULT); - - return (0); -} - - -/* - * dgap_tty_digiseta() - * - * Ioctl to set the information for ditty. - * - * - * - */ -static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - struct digi_t new_digi; - ulong lock_flags = 0; - unsigned long lock_flags2; - - DPR_IOCTL(("DIGI_SETA start\n")); - - if (!tty || tty->magic != TTY_MAGIC) - return (-EFAULT); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-EFAULT); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-EFAULT); - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (-EFAULT); - - if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) { - DPR_IOCTL(("DIGI_SETA failed copy_from_user\n")); - return(-EFAULT); - } - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t)); - - if (ch->ch_digi.digi_maxcps < 1) - ch->ch_digi.digi_maxcps = 1; - - if (ch->ch_digi.digi_maxcps > 10000) - ch->ch_digi.digi_maxcps = 10000; - - if (ch->ch_digi.digi_bufsize < 10) - ch->ch_digi.digi_bufsize = 10; - - if (ch->ch_digi.digi_maxchar < 1) - ch->ch_digi.digi_maxchar = 1; - - if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize) - ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize; - - if (ch->ch_digi.digi_onlen > DIGI_PLEN) - ch->ch_digi.digi_onlen = DIGI_PLEN; - - if (ch->ch_digi.digi_offlen > DIGI_PLEN) - ch->ch_digi.digi_offlen = DIGI_PLEN; - - dgap_param(tty); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("DIGI_SETA finish\n")); - - return(0); -} - - -/* - * dgap_tty_digigetedelay() - * - * Ioctl to get the current edelay setting. - * - * - * - */ -static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo) -{ - struct channel_t *ch; - struct un_t *un; - int tmp; - ulong lock_flags; - - if (!retinfo) - return (-EFAULT); - - if (!tty || tty->magic != TTY_MAGIC) - return (-EFAULT); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-EFAULT); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-EFAULT); - - memset(&tmp, 0, sizeof(tmp)); - - DGAP_LOCK(ch->ch_lock, lock_flags); - tmp = readw(&(ch->ch_bs->edelay)); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return (-EFAULT); - - return (0); -} - - -/* - * dgap_tty_digisetedelay() - * - * Ioctl to set the EDELAY setting - * - */ -static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int new_digi; - ulong lock_flags; - ulong lock_flags2; - - DPR_IOCTL(("DIGI_SETA start\n")); - - if (!tty || tty->magic != TTY_MAGIC) - return (-EFAULT); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-EFAULT); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-EFAULT); - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (-EFAULT); - - if (copy_from_user(&new_digi, new_info, sizeof(int))) { - DPR_IOCTL(("DIGI_SETEDELAY failed copy_from_user\n")); - return(-EFAULT); - } - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - writew((u16) new_digi, &(ch->ch_bs->edelay)); - - dgap_param(tty); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("DIGI_SETA finish\n")); - - return(0); -} - - -/* - * dgap_tty_digigetcustombaud() - * - * Ioctl to get the current custom baud rate setting. - */ -static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo) -{ - struct channel_t *ch; - struct un_t *un; - int tmp; - ulong lock_flags; - - if (!retinfo) - return (-EFAULT); - - if (!tty || tty->magic != TTY_MAGIC) - return (-EFAULT); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-EFAULT); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-EFAULT); - - memset(&tmp, 0, sizeof(tmp)); - - DGAP_LOCK(ch->ch_lock, lock_flags); - tmp = dgap_get_custom_baud(ch); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - DPR_IOCTL(("DIGI_GETCUSTOMBAUD. Returning %d\n", tmp)); - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return (-EFAULT); - - return (0); -} - - -/* - * dgap_tty_digisetcustombaud() - * - * Ioctl to set the custom baud rate setting - */ -static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - uint new_rate; - ulong lock_flags; - ulong lock_flags2; - - DPR_IOCTL(("DIGI_SETCUSTOMBAUD start\n")); - - if (!tty || tty->magic != TTY_MAGIC) - return (-EFAULT); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-EFAULT); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-EFAULT); - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (-EFAULT); - - - if (copy_from_user(&new_rate, new_info, sizeof(unsigned int))) { - DPR_IOCTL(("DIGI_SETCUSTOMBAUD failed copy_from_user\n")); - return(-EFAULT); - } - - if (bd->bd_flags & BD_FEP5PLUS) { - - DPR_IOCTL(("DIGI_SETCUSTOMBAUD. Setting %d\n", new_rate)); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - ch->ch_custom_speed = new_rate; - - dgap_param(tty); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - } - - DPR_IOCTL(("DIGI_SETCUSTOMBAUD finish\n")); - - return(0); -} - - -/* - * dgap_set_termios() - */ -static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - unsigned long lock_flags; - unsigned long lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - ch->ch_c_cflag = tty->termios.c_cflag; - ch->ch_c_iflag = tty->termios.c_iflag; - ch->ch_c_oflag = tty->termios.c_oflag; - ch->ch_c_lflag = tty->termios.c_lflag; - ch->ch_startc = tty->termios.c_cc[VSTART]; - ch->ch_stopc = tty->termios.c_cc[VSTOP]; - - dgap_carrier(ch); - dgap_param(tty); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); -} - - -static void dgap_tty_throttle(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_throttle start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - ch->ch_flags |= (CH_RXBLOCK); -#if 1 - dgap_cmdw(ch, RPAUSE, 0, 0); -#endif - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_throttle finish\n")); -} - - -static void dgap_tty_unthrottle(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_unthrottle start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - ch->ch_flags &= ~(CH_RXBLOCK); - -#if 1 - dgap_cmdw(ch, RRESUME, 0, 0); -#endif - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_unthrottle finish\n")); -} - - -static void dgap_tty_start(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_start start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - dgap_cmdw(ch, RESUMETX, 0, 0); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_start finish\n")); -} - - -static void dgap_tty_stop(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_stop start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - dgap_cmdw(ch, PAUSETX, 0, 0); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_stop finish\n")); -} - - -/* - * dgap_tty_flush_chars() - * - * Flush the cook buffer - * - * Note to self, and any other poor souls who venture here: - * - * flush in this case DOES NOT mean dispose of the data. - * instead, it means "stop buffering and send it if you - * haven't already." Just guess how I figured that out... SRW 2-Jun-98 - * - * It is also always called in interrupt context - JAR 8-Sept-99 - */ -static void dgap_tty_flush_chars(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_flush_chars start\n")); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - /* TODO: Do something here */ - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_flush_chars finish\n")); -} - - - -/* - * dgap_tty_flush_buffer() - * - * Flush Tx buffer (make in == out) - */ -static void dgap_tty_flush_buffer(struct tty_struct *tty) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - u16 head = 0; - - if (!tty || tty->magic != TTY_MAGIC) - return; - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; - - DPR_IOCTL(("dgap_tty_flush_buffer on port: %d start\n", ch->ch_portnum)); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - ch->ch_flags &= ~CH_STOP; - head = readw(&(ch->ch_bs->tx_head)); - dgap_cmdw(ch, FLUSHTX, (u16) head, 0); - dgap_cmdw(ch, RESUMETX, 0, 0); - if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { - ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); - wake_up_interruptible(&ch->ch_tun.un_flags_wait); - } - if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { - ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); - wake_up_interruptible(&ch->ch_pun.un_flags_wait); - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - if (waitqueue_active(&tty->write_wait)) - wake_up_interruptible(&tty->write_wait); - tty_wakeup(tty); - - DPR_IOCTL(("dgap_tty_flush_buffer finish\n")); -} - - - -/***************************************************************************** - * - * The IOCTL function and all of its helpers - * - *****************************************************************************/ - -/* - * dgap_tty_ioctl() - * - * The usual assortment of ioctl's - */ -static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, - unsigned long arg) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int rc; - u16 head = 0; - ulong lock_flags = 0; - ulong lock_flags2 = 0; - void __user *uarg = (void __user *) arg; - - if (!tty || tty->magic != TTY_MAGIC) - return (-ENODEV); - - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (-ENODEV); - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (-ENODEV); - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (-ENODEV); - - DPR_IOCTL(("dgap_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", - ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - if (un->un_open_count <= 0) { - DPR_BASIC(("dgap_tty_ioctl - unit not open.\n")); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(-EIO); - } - - switch (cmd) { - - /* Here are all the standard ioctl's that we MUST implement */ - - case TCSBRK: - /* - * TCSBRK is SVID version: non-zero arg --> no break - * this behaviour is exploited by tcdrain(). - * - * According to POSIX.1 spec (7.2.2.1.2) breaks should be - * between 0.25 and 0.5 seconds so we'll ask for something - * in the middle: 0.375 seconds. - */ - rc = tty_check_change(tty); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - if (rc) { - return(rc); - } - - rc = dgap_wait_for_drain(tty); - - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return(-EINTR); - } - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - if(((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", - ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - return(0); - - - case TCSBRKP: - /* support for POSIX tcsendbreak() - - * According to POSIX.1 spec (7.2.2.1.2) breaks should be - * between 0.25 and 0.5 seconds so we'll ask for something - * in the middle: 0.375 seconds. - */ - rc = tty_check_change(tty); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - if (rc) { - return(rc); - } - - rc = dgap_wait_for_drain(tty); - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return(-EINTR); - } - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", - ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - return(0); - - case TIOCSBRK: - /* - * FEP5 doesn't support turning on a break unconditionally. - * The FEP5 device will stop sending a break automatically - * after the specified time value that was sent when turning on - * the break. - */ - rc = tty_check_change(tty); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - if (rc) { - return(rc); - } - - rc = dgap_wait_for_drain(tty); - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return(-EINTR); - } - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", - ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - return 0; - - case TIOCCBRK: - /* - * FEP5 doesn't support turning off a break unconditionally. - * The FEP5 device will stop sending a break automatically - * after the specified time value that was sent when turning on - * the break. - */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return 0; - - case TIOCGSOFTCAR: - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); - return(rc); - - case TIOCSSOFTCAR: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - rc = get_user(arg, (unsigned long __user *) arg); - if (rc) - return(rc); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); - dgap_param(tty); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - return(0); - - case TIOCMGET: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_get_modem_info(ch, uarg)); - - case TIOCMBIS: - case TIOCMBIC: - case TIOCMSET: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_set_modem_info(tty, cmd, uarg)); - - /* - * Here are any additional ioctl's that we want to implement - */ - - case TCFLSH: - /* - * The linux tty driver doesn't have a flush - * input routine for the driver, assuming all backed - * up data is in the line disc. buffers. However, - * we all know that's not the case. Here, we - * act on the ioctl, but then lie and say we didn't - * so the line discipline will process the flush - * also. - */ - rc = tty_check_change(tty); - if (rc) { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(rc); - } - - if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) { - if (!(un->un_type == DGAP_PRINT)) { - head = readw(&(ch->ch_bs->rx_head)); - writew(head, &(ch->ch_bs->rx_tail)); - writeb(0, &(ch->ch_bs->orun)); - } - } - - if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) { - ch->ch_flags &= ~CH_STOP; - head = readw(&(ch->ch_bs->tx_head)); - dgap_cmdw(ch, FLUSHTX, (u16) head, 0 ); - dgap_cmdw(ch, RESUMETX, 0, 0); - if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { - ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); - wake_up_interruptible(&ch->ch_tun.un_flags_wait); - } - if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { - ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); - wake_up_interruptible(&ch->ch_pun.un_flags_wait); - } - if (waitqueue_active(&tty->write_wait)) - wake_up_interruptible(&tty->write_wait); - - /* Can't hold any locks when calling tty_wakeup! */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - tty_wakeup(tty); - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - } - - /* pretend we didn't recognize this IOCTL */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", - __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - return(-ENOIOCTLCMD); - - case TCSETSF: - case TCSETSW: - /* - * The linux tty driver doesn't have a flush - * input routine for the driver, assuming all backed - * up data is in the line disc. buffers. However, - * we all know that's not the case. Here, we - * act on the ioctl, but then lie and say we didn't - * so the line discipline will process the flush - * also. - */ - if (cmd == TCSETSF) { - /* flush rx */ - ch->ch_flags &= ~CH_STOP; - head = readw(&(ch->ch_bs->rx_head)); - writew(head, &(ch->ch_bs->rx_tail)); - } - - /* now wait for all the output to drain */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - rc = dgap_wait_for_drain(tty); - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return(-EINTR); - } - - DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", - ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - /* pretend we didn't recognize this */ - return(-ENOIOCTLCMD); - - case TCSETAW: - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - rc = dgap_wait_for_drain(tty); - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return(-EINTR); - } - - /* pretend we didn't recognize this */ - return(-ENOIOCTLCMD); - - case TCXONC: - /* - * The Linux Line Discipline (LD) would do this for us if we - * let it, but we have the special firmware options to do this - * the "right way" regardless of hardware or software flow - * control so we'll do it outselves instead of letting the LD - * do it. - */ - rc = tty_check_change(tty); - if (rc) { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(rc); - } - - DPR_IOCTL(("dgap_ioctl - in TCXONC - %d\n", cmd)); - switch (arg) { - - case TCOON: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - dgap_tty_start(tty); - return(0); - case TCOOFF: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - dgap_tty_stop(tty); - return(0); - case TCION: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - /* Make the ld do it */ - return(-ENOIOCTLCMD); - case TCIOFF: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - /* Make the ld do it */ - return(-ENOIOCTLCMD); - default: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(-EINVAL); - } - - case DIGI_GETA: - /* get information for ditty */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_tty_digigeta(tty, uarg)); - - case DIGI_SETAW: - case DIGI_SETAF: - - /* set information for ditty */ - if (cmd == (DIGI_SETAW)) { - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - rc = dgap_wait_for_drain(tty); - if (rc) { - DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); - return(-EINTR); - } - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - } - else { - tty_ldisc_flush(tty); - } - /* fall thru */ - - case DIGI_SETA: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_tty_digiseta(tty, uarg)); - - case DIGI_GEDELAY: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_tty_digigetedelay(tty, uarg)); - - case DIGI_SEDELAY: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_tty_digisetedelay(tty, uarg)); - - case DIGI_GETCUSTOMBAUD: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_tty_digigetcustombaud(tty, uarg)); - - case DIGI_SETCUSTOMBAUD: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return(dgap_tty_digisetcustombaud(tty, uarg)); - - case DIGI_RESET_PORT: - dgap_firmware_reset_port(ch); - dgap_param(tty); - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return 0; - - default: - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_IOCTL(("dgap_tty_ioctl - in default\n")); - DPR_IOCTL(("dgap_tty_ioctl end - cmd %s (%x), arg %lx\n", - dgap_ioctl_name(cmd), cmd, arg)); - - return(-ENOIOCTLCMD); - } -} From b053bb86a96e49761b36a1f7c9cec1d7f8de0c08 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:00 -0500 Subject: [PATCH 0436/1375] staging: dgap: Merge dgap_fep5.c into dgap_driver.c There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 2 +- drivers/staging/dgap/dgap_driver.c | 1857 +++++++++++++++++++++++++++ drivers/staging/dgap/dgap_fep5.c | 1902 ---------------------------- 3 files changed, 1858 insertions(+), 1903 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_fep5.c diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index b80cad5f95c5..867b1e5d6fcb 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -1,7 +1,7 @@ obj-$(CONFIG_DGAP) += dgap.o -dgap-objs := dgap_driver.o dgap_fep5.o \ +dgap-objs := dgap_driver.o \ dgap_parse.o dgap_trace.o \ dgap_sysfs.o diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index b49f6988a7f6..db4da9a26092 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -126,6 +126,12 @@ static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c); static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); +/* + * Our function prototypes from dgap_fep5 + */ +static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); +static int dgap_event(struct board_t *bd); + /* Driver load/unload functions */ int dgap_init_module(void); void dgap_cleanup_module(void); @@ -168,6 +174,7 @@ static struct class * dgap_class; static struct board_t *dgap_BoardsByMajor[256]; static uchar *dgap_TmpWriteBuf = NULL; static DECLARE_MUTEX(dgap_TmpWriteSem); +static uint dgap_count = 500; /* * Poller stuff @@ -4522,3 +4529,1853 @@ static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return(-ENOIOCTLCMD); } } +/* + * Loads the dgap.conf config file from the user. + */ +void dgap_do_config_load(uchar __user *uaddr, int len) +{ + int orig_len = len; + char *to_addr; + uchar __user *from_addr = uaddr; + char buf[U2BSIZE]; + int n; + + to_addr = dgap_config_buf = kzalloc(len + 1, GFP_ATOMIC); + if (!dgap_config_buf) { + DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n")); + dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; + return; + } + + n = U2BSIZE; + while (len) { + + if (n > len) + n = len; + + if (copy_from_user((char *) &buf, from_addr, n) == -1 ) + return; + + /* Copy data from buffer to kernel memory */ + memcpy(to_addr, buf, n); + + /* increment counts */ + len -= n; + to_addr += n; + from_addr += n; + n = U2BSIZE; + } + + dgap_config_buf[orig_len] = '\0'; + + to_addr = dgap_config_buf; + dgap_parsefile(&to_addr, TRUE); + + DPR_INIT(("dgap_config_load() finish\n")); + + return; +} + + +int dgap_after_config_loaded(void) +{ + int i = 0; + int rc = 0; + + /* + * Register our ttys, now that we have the config loaded. + */ + for (i = 0; i < dgap_NumBoards; ++i) { + + /* + * Initialize KME waitqueues... + */ + init_waitqueue_head(&(dgap_Board[i]->kme_wait)); + + /* + * allocate flip buffer for board. + */ + dgap_Board[i]->flipbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); + dgap_Board[i]->flipflagbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); + } + + return rc; +} + + + +/*======================================================================= + * + * usertoboard - copy from user space to board space. + * + *=======================================================================*/ +static int dgap_usertoboard(struct board_t *brd, char *to_addr, char __user *from_addr, int len) +{ + char buf[U2BSIZE]; + int n = U2BSIZE; + + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return -EFAULT; + + while (len) { + if (n > len) + n = len; + + if (copy_from_user((char *) &buf, from_addr, n) == -1 ) { + return -EFAULT; + } + + /* Copy data from buffer to card memory */ + memcpy_toio(to_addr, buf, n); + + /* increment counts */ + len -= n; + to_addr += n; + from_addr += n; + n = U2BSIZE; + } + return 0; +} + + +/* + * Copies the BIOS code from the user to the board, + * and starts the BIOS running. + */ +void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len) +{ + uchar *addr; + uint offset; + int i; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + DPR_INIT(("dgap_do_bios_load() start\n")); + + addr = brd->re_map_membase; + + /* + * clear POST area + */ + for (i = 0; i < 16; i++) + writeb(0, addr + POSTAREA + i); + + /* + * Download bios + */ + offset = 0x1000; + if (dgap_usertoboard(brd, addr + offset, ubios, len) == -1 ) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return; + } + + writel(0x0bf00401, addr); + writel(0, (addr + 4)); + + /* Clear the reset, and change states. */ + writeb(FEPCLR, brd->re_map_port); + brd->state = WAIT_BIOS_LOAD; +} + + +/* + * Checks to see if the BIOS completed running on the card. + */ +static void dgap_do_wait_for_bios(struct board_t *brd) +{ + uchar *addr; + u16 word; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + word = readw(addr + POSTAREA); + + /* Check to see if BIOS thinks board is good. (GD). */ + if (word == *(u16 *) "GD") { + DPR_INIT(("GOT GD in memory, moving states.\n")); + brd->state = FINISHED_BIOS_LOAD; + return; + } + + /* Give up on board after too long of time taken */ + if (brd->wait_for_bios++ > 5000) { + u16 err1 = readw(addr + SEQUENCE); + u16 err2 = readw(addr + ERROR); + APR(("***WARNING*** %s failed diagnostics. Error #(%x,%x).\n", + brd->name, err1, err2)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + } +} + + +/* + * Copies the FEP code from the user to the board, + * and starts the FEP running. + */ +void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) +{ + uchar *addr; + uint offset; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + + DPR_INIT(("dgap_do_fep_load() for board %s : start\n", brd->name)); + + /* + * Download FEP + */ + offset = 0x1000; + if (dgap_usertoboard(brd, addr + offset, ufep, len) == -1 ) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return; + } + + /* + * If board is a concentrator product, we need to give + * it its config string describing how the concentrators look. + */ + if ((brd->type == PCX) || (brd->type == PEPC)) { + uchar string[100]; + uchar *config, *xconfig; + int i = 0; + + xconfig = dgap_create_config_string(brd, string); + + /* Write string to board memory */ + config = addr + CONFIG; + for (; i < CONFIGSIZE; i++, config++, xconfig++) { + writeb(*xconfig, config); + if ((*xconfig & 0xff) == 0xff) + break; + } + } + + writel(0xbfc01004, (addr + 0xc34)); + writel(0x3, (addr + 0xc30)); + + /* change states. */ + brd->state = WAIT_FEP_LOAD; + + DPR_INIT(("dgap_do_fep_load() for board %s : finish\n", brd->name)); + +} + + +/* + * Waits for the FEP to report thats its ready for us to use. + */ +static void dgap_do_wait_for_fep(struct board_t *brd) +{ + uchar *addr; + u16 word; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + + DPR_INIT(("dgap_do_wait_for_fep() for board %s : start. addr: %p\n", brd->name, addr)); + + word = readw(addr + FEPSTAT); + + /* Check to see if FEP is up and running now. */ + if (word == *(u16 *) "OS") { + DPR_INIT(("GOT OS in memory for board %s, moving states.\n", brd->name)); + brd->state = FINISHED_FEP_LOAD; + + /* + * Check to see if the board can support FEP5+ commands. + */ + word = readw(addr + FEP5_PLUS); + if (word == *(u16 *) "5A") { + DPR_INIT(("GOT 5A in memory for board %s, board supports extended FEP5 commands.\n", brd->name)); + brd->bd_flags |= BD_FEP5PLUS; + } + + return; + } + + /* Give up on board after too long of time taken */ + if (brd->wait_for_fep++ > 5000) { + u16 err1 = readw(addr + SEQUENCE); + u16 err2 = readw(addr + ERROR); + APR(("***WARNING*** FEPOS for %s not functioning. Error #(%x,%x).\n", + brd->name, err1, err2)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + } + + DPR_INIT(("dgap_do_wait_for_fep() for board %s : finish\n", brd->name)); +} + + +/* + * Physically forces the FEP5 card to reset itself. + */ +static void dgap_do_reset_board(struct board_t *brd) +{ + uchar check; + u32 check1; + u32 check2; + int i = 0; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase || !brd->re_map_port) { + DPR_INIT(("dgap_do_reset_board() start. bad values. brd: %p mem: %p io: %p\n", + brd, brd ? brd->re_map_membase : 0, brd ? brd->re_map_port : 0)); + return; + } + + DPR_INIT(("dgap_do_reset_board() start. io: %p\n", brd->re_map_port)); + + /* FEPRST does not vary among supported boards */ + writeb(FEPRST, brd->re_map_port); + + for (i = 0; i <= 1000; i++) { + check = readb(brd->re_map_port) & 0xe; + if (check == FEPRST) + break; + udelay(10); + + } + if (i > 1000) { + APR(("*** WARNING *** Board not resetting... Failing board.\n")); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + goto failed; + } + + /* + * Make sure there really is memory out there. + */ + writel(0xa55a3cc3, (brd->re_map_membase + LOWMEM)); + writel(0x5aa5c33c, (brd->re_map_membase + HIGHMEM)); + check1 = readl(brd->re_map_membase + LOWMEM); + check2 = readl(brd->re_map_membase + HIGHMEM); + + if ((check1 != 0xa55a3cc3) || (check2 != 0x5aa5c33c)) { + APR(("*** Warning *** No memory at %p for board.\n", brd->re_map_membase)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + goto failed; + } + + if (brd->state != BOARD_FAILED) + brd->state = FINISHED_RESET; + +failed: + DPR_INIT(("dgap_do_reset_board() finish\n")); +} + + +/* + * Sends a concentrator image into the FEP5 board. + */ +void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) +{ + char *vaddr; + u16 offset = 0; + struct downld_t *to_dp; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + vaddr = brd->re_map_membase; + + offset = readw((u16 *) (vaddr + DOWNREQ)); + to_dp = (struct downld_t *) (vaddr + (int) offset); + + /* + * The image was already read into kernel space, + * we do NOT need a user space read here + */ + memcpy_toio((char *) to_dp, uaddr, sizeof(struct downld_t)); + + /* Tell card we have data for it */ + writew(0, vaddr + (DOWNREQ)); + + brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; +} + + +#define EXPANSION_ROM_SIZE (64 * 1024) +#define FEP5_ROM_MAGIC (0xFEFFFFFF) + +static void dgap_get_vpd(struct board_t *brd) +{ + u32 magic; + u32 base_offset; + u16 rom_offset; + u16 vpd_offset; + u16 image_length; + u16 i; + uchar byte1; + uchar byte2; + + /* + * Poke the magic number at the PCI Rom Address location. + * If VPD is supported, the value read from that address + * will be non-zero. + */ + magic = FEP5_ROM_MAGIC; + pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); + pci_read_config_dword(brd->pdev, PCI_ROM_ADDRESS, &magic); + + /* VPD not supported, bail */ + if (!magic) + return; + + /* + * To get to the OTPROM memory, we have to send the boards base + * address or'ed with 1 into the PCI Rom Address location. + */ + magic = brd->membase | 0x01; + pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); + pci_read_config_dword(brd->pdev, PCI_ROM_ADDRESS, &magic); + + byte1 = readb(brd->re_map_membase); + byte2 = readb(brd->re_map_membase + 1); + + /* + * If the board correctly swapped to the OTPROM memory, + * the first 2 bytes (header) should be 0x55, 0xAA + */ + if (byte1 == 0x55 && byte2 == 0xAA) { + + base_offset = 0; + + /* + * We have to run through all the OTPROM memory looking + * for the VPD offset. + */ + while (base_offset <= EXPANSION_ROM_SIZE) { + + /* + * Lots of magic numbers here. + * + * The VPD offset is located inside the ROM Data Structure. + * We also have to remember the length of each + * ROM Data Structure, so we can "hop" to the next + * entry if the VPD isn't in the current + * ROM Data Structure. + */ + rom_offset = readw(brd->re_map_membase + base_offset + 0x18); + image_length = readw(brd->re_map_membase + rom_offset + 0x10) * 512; + vpd_offset = readw(brd->re_map_membase + rom_offset + 0x08); + + /* Found the VPD entry */ + if (vpd_offset) + break; + + /* We didn't find a VPD entry, go to next ROM entry. */ + base_offset += image_length; + + byte1 = readb(brd->re_map_membase + base_offset); + byte2 = readb(brd->re_map_membase + base_offset + 1); + + /* + * If the new ROM offset doesn't have 0x55, 0xAA + * as its header, we have run out of ROM. + */ + if (byte1 != 0x55 || byte2 != 0xAA) + break; + } + + /* + * If we have a VPD offset, then mark the board + * as having a valid VPD, and copy VPDSIZE (512) bytes of + * that VPD to the buffer we have in our board structure. + */ + if (vpd_offset) { + brd->bd_flags |= BD_HAS_VPD; + for (i = 0; i < VPDSIZE; i++) + brd->vpd[i] = readb(brd->re_map_membase + vpd_offset + i); + } + } + + /* + * We MUST poke the magic number at the PCI Rom Address location again. + * This makes the card report the regular board memory back to us, + * rather than the OTPROM memory. + */ + magic = FEP5_ROM_MAGIC; + pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); +} + + +/* + * Our board poller function. + */ +void dgap_poll_tasklet(unsigned long data) +{ + struct board_t *bd = (struct board_t *) data; + ulong lock_flags; + ulong lock_flags2; + char *vaddr; + u16 head, tail; + u16 *chk_addr; + u16 check = 0; + + if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) { + APR(("dgap_poll_tasklet() - NULL or bad bd.\n")); + return; + } + + if (bd->inhibit_poller) + return; + + DGAP_LOCK(bd->bd_lock, lock_flags); + + vaddr = bd->re_map_membase; + + /* + * If board is ready, parse deeper to see if there is anything to do. + */ + if (bd->state == BOARD_READY) { + + struct ev_t *eaddr = NULL; + + if (!bd->re_map_membase) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + if (!bd->re_map_port) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + + if (!bd->nasync) { + goto out; + } + + /* + * If this is a CX or EPCX, we need to see if the firmware + * is requesting a concentrator image from us. + */ + if ((bd->type == PCX) || (bd->type == PEPC)) { + chk_addr = (u16 *) (vaddr + DOWNREQ); + check = readw(chk_addr); + /* Nonzero if FEP is requesting concentrator image. */ + if (check) { + if (bd->conc_dl_status == NO_PENDING_CONCENTRATOR_REQUESTS) + bd->conc_dl_status = NEED_CONCENTRATOR; + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + + } + } + + eaddr = (struct ev_t *) (vaddr + EVBUF); + + /* Get our head and tail */ + head = readw(&(eaddr->ev_head)); + tail = readw(&(eaddr->ev_tail)); + + /* + * If there is an event pending. Go service it. + */ + if (head != tail) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + dgap_event(bd); + DGAP_LOCK(bd->bd_lock, lock_flags); + } + +out: + /* + * If board is doing interrupts, ACK the interrupt. + */ + if (bd && bd->intr_running) { + readb(bd->re_map_port + 2); + } + + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + + /* Our state machine to get the board up and running */ + + /* Reset board */ + if (bd->state == NEED_RESET) { + + /* Get VPD info */ + dgap_get_vpd(bd); + + dgap_do_reset_board(bd); + } + + /* Move to next state */ + if (bd->state == FINISHED_RESET) { + bd->state = NEED_CONFIG; + } + + if (bd->state == NEED_CONFIG) { + /* + * Match this board to a config the user created for us. + */ + bd->bd_config = dgap_find_config(bd->type, bd->pci_bus, bd->pci_slot); + + /* + * Because the 4 port Xr products share the same PCI ID + * as the 8 port Xr products, if we receive a NULL config + * back, and this is a PAPORT8 board, retry with a + * PAPORT4 attempt as well. + */ + if (bd->type == PAPORT8 && !bd->bd_config) { + bd->bd_config = dgap_find_config(PAPORT4, bd->pci_bus, bd->pci_slot); + } + + /* + * Register the ttys (if any) into the kernel. + */ + if (bd->bd_config) { + bd->state = FINISHED_CONFIG; + } + else { + bd->state = CONFIG_NOT_FOUND; + } + } + + /* Move to next state */ + if (bd->state == FINISHED_CONFIG) { + bd->state = NEED_DEVICE_CREATION; + } + + /* Move to next state */ + if (bd->state == NEED_DEVICE_CREATION) { + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + + /* Move to next state */ + if (bd->state == FINISHED_DEVICE_CREATION) { + bd->state = NEED_BIOS_LOAD; + } + + /* Move to next state */ + if (bd->state == NEED_BIOS_LOAD) { + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + + /* Wait for BIOS to test board... */ + if (bd->state == WAIT_BIOS_LOAD) { + dgap_do_wait_for_bios(bd); + } + + /* Move to next state */ + if (bd->state == FINISHED_BIOS_LOAD) { + bd->state = NEED_FEP_LOAD; + + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + + /* Wait for FEP to load on board... */ + if (bd->state == WAIT_FEP_LOAD) { + dgap_do_wait_for_fep(bd); + } + + + /* Move to next state */ + if (bd->state == FINISHED_FEP_LOAD) { + + /* + * Do tty device initialization. + */ + int rc = dgap_tty_init(bd); + + if (rc < 0) { + dgap_tty_uninit(bd); + APR(("Can't init tty devices (%d)\n", rc)); + bd->state = BOARD_FAILED; + bd->dpastatus = BD_NOFEP; + } + else { + bd->state = NEED_PROC_CREATION; + + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + } + + /* Move to next state */ + if (bd->state == FINISHED_PROC_CREATION) { + + bd->state = BOARD_READY; + bd->dpastatus = BD_RUNNING; + + /* + * If user requested the board to run in interrupt mode, + * go and set it up on the board. + */ + if (bd->intr_used) { + writew(1, (bd->re_map_membase + ENABLE_INTR)); + /* + * Tell the board to poll the UARTS as fast as possible. + */ + writew(FEPPOLL_MIN, (bd->re_map_membase + FEPPOLL)); + bd->intr_running = 1; + } + + /* Wake up anyone waiting for board state to change to ready */ + wake_up_interruptible(&bd->state_wait); + } + + DGAP_UNLOCK(bd->bd_lock, lock_flags); +} + + +/*======================================================================= + * + * dgap_cmdb - Sends a 2 byte command to the FEP. + * + * ch - Pointer to channel structure. + * cmd - Command to be sent. + * byte1 - Integer containing first byte to be sent. + * byte2 - Integer containing second byte to be sent. + * ncmds - Wait until ncmds or fewer cmds are left + * in the cmd buffer before returning. + * + *=======================================================================*/ +void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds) +{ + char *vaddr = NULL; + struct cm_t *cm_addr = NULL; + uint count; + uint n; + u16 head; + u16 tail; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + DPR_CORE(("%s:%d board is in failed state.\n", __FILE__, __LINE__)); + return; + } + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + + if (!vaddr) + return; + + cm_addr = (struct cm_t *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + DPR_CORE(("%s:%d pointers out of range, failing board!\n", __FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + + /* + * Put the data in the circular command buffer. + */ + writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); + writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writeb(byte1, (char *) (vaddr + head + CMDSTART + 2)); + writeb(byte2, (char *) (vaddr + head + CMDSTART + 3)); + + head = (head + 4) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); + + /* + * Wait if necessary before updating the head + * pointer to limit the number of outstanding + * commands to the FEP. If the time spent waiting + * is outlandish, declare the FEP dead. + */ + for (count = dgap_count ;;) { + + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); + + n = (head - tail) & (CMDMAX - CMDSTART - 4); + + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + DPR_CORE(("%s:%d failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} + + +/*======================================================================= + * + * dgap_cmdw - Sends a 1 word command to the FEP. + * + * ch - Pointer to channel structure. + * cmd - Command to be sent. + * word - Integer containing word to be sent. + * ncmds - Wait until ncmds or fewer cmds are left + * in the cmd buffer before returning. + * + *=======================================================================*/ +void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) +{ + char *vaddr = NULL; + struct cm_t *cm_addr = NULL; + uint count; + uint n; + u16 head; + u16 tail; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__)); + return; + } + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + if (!vaddr) + return; + + cm_addr = (struct cm_t *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + + /* + * Put the data in the circular command buffer. + */ + writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); + writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writew((u16) word, (char *) (vaddr + head + CMDSTART + 2)); + + head = (head + 4) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); + + /* + * Wait if necessary before updating the head + * pointer to limit the number of outstanding + * commands to the FEP. If the time spent waiting + * is outlandish, declare the FEP dead. + */ + for (count = dgap_count ;;) { + + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); + + n = (head - tail) & (CMDMAX - CMDSTART - 4); + + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} + + + +/*======================================================================= + * + * dgap_cmdw_ext - Sends a extended word command to the FEP. + * + * ch - Pointer to channel structure. + * cmd - Command to be sent. + * word - Integer containing word to be sent. + * ncmds - Wait until ncmds or fewer cmds are left + * in the cmd buffer before returning. + * + *=======================================================================*/ +static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) +{ + char *vaddr = NULL; + struct cm_t *cm_addr = NULL; + uint count; + uint n; + u16 head; + u16 tail; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__)); + return; + } + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + if (!vaddr) + return; + + cm_addr = (struct cm_t *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + + /* + * Put the data in the circular command buffer. + */ + + /* Write an FF to tell the FEP that we want an extended command */ + writeb((uchar) 0xff, (char *) (vaddr + head + CMDSTART + 0)); + + writeb((uchar) ch->ch_portnum, (uchar *) (vaddr + head + CMDSTART + 1)); + writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2)); + + /* + * If the second part of the command won't fit, + * put it at the beginning of the circular buffer. + */ + if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03))) { + writew((u16) word, (char *) (vaddr + CMDSTART)); + } else { + writew((u16) word, (char *) (vaddr + head + CMDSTART + 4)); + } + + head = (head + 8) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); + + /* + * Wait if necessary before updating the head + * pointer to limit the number of outstanding + * commands to the FEP. If the time spent waiting + * is outlandish, declare the FEP dead. + */ + for (count = dgap_count ;;) { + + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); + + n = (head - tail) & (CMDMAX - CMDSTART - 4); + + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} + + +/*======================================================================= + * + * dgap_wmove - Write data to FEP buffer. + * + * ch - Pointer to channel structure. + * buf - Poiter to characters to be moved. + * cnt - Number of characters to move. + * + *=======================================================================*/ +void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) +{ + int n; + char *taddr; + struct bs_t *bs; + u16 head; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check parameters. + */ + bs = ch->ch_bs; + head = readw(&(bs->tx_head)); + + /* + * If pointers are out of range, just return. + */ + if ((cnt > ch->ch_tsize) || (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize) { + DPR_CORE(("%s:%d pointer out of range", __FILE__, __LINE__)); + return; + } + + /* + * If the write wraps over the top of the circular buffer, + * move the portion up to the wrap point, and reset the + * pointers to the bottom. + */ + n = ch->ch_tstart + ch->ch_tsize - head; + + if (cnt >= n) { + cnt -= n; + taddr = ch->ch_taddr + head; + memcpy_toio(taddr, buf, n); + head = ch->ch_tstart; + buf += n; + } + + /* + * Move rest of data. + */ + taddr = ch->ch_taddr + head; + n = cnt; + memcpy_toio(taddr, buf, n); + head += cnt; + + writew(head, &(bs->tx_head)); +} + +/* + * Retrives the current custom baud rate from FEP memory, + * and returns it back to the user. + * Returns 0 on error. + */ +uint dgap_get_custom_baud(struct channel_t *ch) +{ + uchar *vaddr; + ulong offset = 0; + uint value = 0; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { + return 0; + } + + if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC) { + return 0; + } + + if (!(ch->ch_bd->bd_flags & BD_FEP5PLUS)) + return 0; + + vaddr = ch->ch_bd->re_map_membase; + + if (!vaddr) + return 0; + + /* + * Go get from fep mem, what the fep + * believes the custom baud rate is. + */ + offset = ((((*(unsigned short *)(vaddr + ECS_SEG)) << 4) + + (ch->ch_portnum * 0x28) + LINE_SPEED)); + + value = readw(vaddr + offset); + return value; +} + + +/* + * Calls the firmware to reset this channel. + */ +void dgap_firmware_reset_port(struct channel_t *ch) +{ + dgap_cmdb(ch, CHRESET, 0, 0, 0); + + /* + * Now that the channel is reset, we need to make sure + * all the current settings get reapplied to the port + * in the firmware. + * + * So we will set the driver's cache of firmware + * settings all to 0, and then call param. + */ + ch->ch_fepiflag = 0; + ch->ch_fepcflag = 0; + ch->ch_fepoflag = 0; + ch->ch_fepstartc = 0; + ch->ch_fepstopc = 0; + ch->ch_fepastartc = 0; + ch->ch_fepastopc = 0; + ch->ch_mostat = 0; + ch->ch_hflow = 0; +} + + +/*======================================================================= + * + * dgap_param - Set Digi parameters. + * + * struct tty_struct * - TTY for port. + * + *=======================================================================*/ +int dgap_param(struct tty_struct *tty) +{ + struct ktermios *ts; + struct board_t *bd; + struct channel_t *ch; + struct bs_t *bs; + struct un_t *un; + u16 head; + u16 cflag; + u16 iflag; + uchar mval; + uchar hflow; + + if (!tty || tty->magic != TTY_MAGIC) + return -ENXIO; + + un = (struct un_t *) tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return -ENXIO; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return -ENXIO; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return -ENXIO; + + bs = ch->ch_bs; + if (!bs) + return -ENXIO; + + DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", + ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); + + ts = &tty->termios; + + /* + * If baud rate is zero, flush queues, and set mval to drop DTR. + */ + if ((ch->ch_c_cflag & (CBAUD)) == 0) { + + /* flush rx */ + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + + /* flush tx */ + head = readw(&(ch->ch_bs->tx_head)); + writew(head, &(ch->ch_bs->tx_tail)); + + ch->ch_flags |= (CH_BAUD0); + + /* Drop RTS and DTR */ + ch->ch_mval &= ~(D_RTS(ch)|D_DTR(ch)); + mval = D_DTR(ch) | D_RTS(ch); + ch->ch_baud_info = 0; + + } else if (ch->ch_custom_speed && (bd->bd_flags & BD_FEP5PLUS)) { + /* + * Tell the fep to do the command + */ + + DPR_PARAM(("param: Want %d speed\n", ch->ch_custom_speed)); + + dgap_cmdw_ext(ch, 0xff01, ch->ch_custom_speed, 0); + + /* + * Now go get from fep mem, what the fep + * believes the custom baud rate is. + */ + ch->ch_baud_info = ch->ch_custom_speed = dgap_get_custom_baud(ch); + + DPR_PARAM(("param: Got %d speed\n", ch->ch_custom_speed)); + + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + ch->ch_mval |= (D_RTS(ch)|D_DTR(ch)); + } + mval = D_DTR(ch) | D_RTS(ch); + + } else { + /* + * Set baud rate, character size, and parity. + */ + + + int iindex = 0; + int jindex = 0; + int baud = 0; + + ulong bauds[4][16] = { + { /* slowbaud */ + 0, 50, 75, 110, + 134, 150, 200, 300, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* slowbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* fastbaud */ + 0, 57600, 76800, 115200, + 14400, 57600, 230400, 76800, + 115200, 230400, 28800, 460800, + 921600, 9600, 19200, 38400 }, + { /* fastbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 } + }; + + /* Only use the TXPrint baud rate if the terminal unit is NOT open */ + if (!(ch->ch_tun.un_flags & UN_ISOPEN) && (un->un_type == DGAP_PRINT)) + baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; + else + baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; + + if (ch->ch_c_cflag & CBAUDEX) + iindex = 1; + + if (ch->ch_digi.digi_flags & DIGI_FAST) + iindex += 2; + + jindex = baud; + + if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { + baud = bauds[iindex][jindex]; + } else { + DPR_IOCTL(("baud indices were out of range (%d)(%d)", + iindex, jindex)); + baud = 0; + } + + if (baud == 0) + baud = 9600; + + ch->ch_baud_info = baud; + + + /* + * CBAUD has bit position 0x1000 set these days to indicate Linux + * baud rate remap. + * We use a different bit assignment for high speed. Clear this + * bit out while grabbing the parts of "cflag" we want. + */ + cflag = ch->ch_c_cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); + + /* + * HUPCL bit is used by FEP to indicate fast baud + * table is to be used. + */ + if ((ch->ch_digi.digi_flags & DIGI_FAST) || (ch->ch_c_cflag & CBAUDEX)) + cflag |= HUPCL; + + + if ((ch->ch_c_cflag & CBAUDEX) && !(ch->ch_digi.digi_flags & DIGI_FAST)) { + /* + * The below code is trying to guarantee that only baud rates + * 115200, 230400, 460800, 921600 are remapped. We use exclusive or + * because the various baud rates share common bit positions + * and therefore can't be tested for easily. + */ + tcflag_t tcflag = (ch->ch_c_cflag & CBAUD) | CBAUDEX; + int baudpart = 0; + + /* Map high speed requests to index into FEP's baud table */ + switch (tcflag) { + case B57600 : + baudpart = 1; + break; +#ifdef B76800 + case B76800 : + baudpart = 2; + break; +#endif + case B115200 : + baudpart = 3; + break; + case B230400 : + baudpart = 9; + break; + case B460800 : + baudpart = 11; + break; +#ifdef B921600 + case B921600 : + baudpart = 12; + break; +#endif + default: + baudpart = 0; + } + + if (baudpart) + cflag = (cflag & ~(CBAUD | CBAUDEX)) | baudpart; + } + + cflag &= 0xffff; + + if (cflag != ch->ch_fepcflag) { + ch->ch_fepcflag = (u16) (cflag & 0xffff); + + /* Okay to have channel and board locks held calling this */ + dgap_cmdw(ch, SCFLAG, (u16) cflag, 0); + } + + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + ch->ch_mval |= (D_RTS(ch)|D_DTR(ch)); + } + mval = D_DTR(ch) | D_RTS(ch); + } + + /* + * Get input flags. + */ + iflag = ch->ch_c_iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | IXON | IXANY | IXOFF); + + if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) { + iflag &= ~(IXON | IXOFF); + ch->ch_c_iflag &= ~(IXON | IXOFF); + } + + /* + * Only the IBM Xr card can switch between + * 232 and 422 modes on the fly + */ + if (bd->device == PCI_DEVICE_XR_IBM_DID) { + if (ch->ch_digi.digi_flags & DIGI_422) + dgap_cmdb(ch, SCOMMODE, MODE_422, 0, 0); + else + dgap_cmdb(ch, SCOMMODE, MODE_232, 0, 0); + } + + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) + iflag |= IALTPIN ; + + if (iflag != ch->ch_fepiflag) { + ch->ch_fepiflag = iflag; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdw(ch, SIFLAG, (u16) ch->ch_fepiflag, 0); + } + + /* + * Select hardware handshaking. + */ + hflow = 0; + + if (ch->ch_c_cflag & CRTSCTS) { + hflow |= (D_RTS(ch) | D_CTS(ch)); + } + if (ch->ch_digi.digi_flags & RTSPACE) + hflow |= D_RTS(ch); + if (ch->ch_digi.digi_flags & DTRPACE) + hflow |= D_DTR(ch); + if (ch->ch_digi.digi_flags & CTSPACE) + hflow |= D_CTS(ch); + if (ch->ch_digi.digi_flags & DSRPACE) + hflow |= D_DSR(ch); + if (ch->ch_digi.digi_flags & DCDPACE) + hflow |= D_CD(ch); + + if (hflow != ch->ch_hflow) { + ch->ch_hflow = hflow; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SHFLOW, (uchar) hflow, 0xff, 0); + } + + + /* + * Set RTS and/or DTR Toggle if needed, but only if product is FEP5+ based. + */ + if (bd->bd_flags & BD_FEP5PLUS) { + u16 hflow2 = 0; + if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { + hflow2 |= (D_RTS(ch)); + } + if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { + hflow2 |= (D_DTR(ch)); + } + + dgap_cmdw_ext(ch, 0xff03, hflow2, 0); + } + + /* + * Set modem control lines. + */ + + mval ^= ch->ch_mforce & (mval ^ ch->ch_mval); + + DPR_PARAM(("dgap_param: mval: %x ch_mforce: %x ch_mval: %x ch_mostat: %x\n", + mval, ch->ch_mforce, ch->ch_mval, ch->ch_mostat)); + + if (ch->ch_mostat ^ mval) { + ch->ch_mostat = mval; + + /* Okay to have channel and board locks held calling this */ + DPR_PARAM(("dgap_param: Sending SMODEM mval: %x\n", mval)); + dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0); + } + + /* + * Read modem signals, and then call carrier function. + */ + ch->ch_mistat = readb(&(bs->m_stat)); + dgap_carrier(ch); + + /* + * Set the start and stop characters. + */ + if (ch->ch_startc != ch->ch_fepstartc || ch->ch_stopc != ch->ch_fepstopc) { + ch->ch_fepstartc = ch->ch_startc; + ch->ch_fepstopc = ch->ch_stopc; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SFLOWC, ch->ch_fepstartc, ch->ch_fepstopc, 0); + } + + /* + * Set the Auxiliary start and stop characters. + */ + if (ch->ch_astartc != ch->ch_fepastartc || ch->ch_astopc != ch->ch_fepastopc) { + ch->ch_fepastartc = ch->ch_astartc; + ch->ch_fepastopc = ch->ch_astopc; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SAFLOWC, ch->ch_fepastartc, ch->ch_fepastopc, 0); + } + + DPR_PARAM(("param finish\n")); + + return 0; +} + + +/* + * dgap_parity_scan() + * + * Convert the FEP5 way of reporting parity errors and breaks into + * the Linux line discipline way. + */ +void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len) +{ + int l = *len; + int count = 0; + unsigned char *in, *cout, *fout; + unsigned char c; + + in = cbuf; + cout = cbuf; + fout = fbuf; + + DPR_PSCAN(("dgap_parity_scan start\n")); + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + while (l--) { + c = *in++; + switch (ch->pscan_state) { + default: + /* reset to sanity and fall through */ + ch->pscan_state = 0; + + case 0: + /* No FF seen yet */ + if (c == (unsigned char) '\377') { + /* delete this character from stream */ + ch->pscan_state = 1; + } else { + *cout++ = c; + *fout++ = TTY_NORMAL; + count += 1; + } + break; + + case 1: + /* first FF seen */ + if (c == (unsigned char) '\377') { + /* doubled ff, transform to single ff */ + *cout++ = c; + *fout++ = TTY_NORMAL; + count += 1; + ch->pscan_state = 0; + } else { + /* save value examination in next state */ + ch->pscan_savechar = c; + ch->pscan_state = 2; + } + break; + + case 2: + /* third character of ff sequence */ + + *cout++ = c; + + if (ch->pscan_savechar == 0x0) { + + if (c == 0x0) { + DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting break.\n", c)); + ch->ch_err_break++; + *fout++ = TTY_BREAK; + } + else { + DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting parity.\n", c)); + ch->ch_err_parity++; + *fout++ = TTY_PARITY; + } + } + else { + DPR_PSCAN(("%s:%d Logic Error.\n", __FILE__, __LINE__)); + } + + count += 1; + ch->pscan_state = 0; + } + } + *len = count; + DPR_PSCAN(("dgap_parity_scan finish\n")); +} + + + + +/*======================================================================= + * + * dgap_event - FEP to host event processing routine. + * + * bd - Board of current event. + * + *=======================================================================*/ +static int dgap_event(struct board_t *bd) +{ + struct channel_t *ch; + ulong lock_flags; + ulong lock_flags2; + struct bs_t *bs; + uchar *event; + uchar *vaddr = NULL; + struct ev_t *eaddr = NULL; + uint head; + uint tail; + int port; + int reason; + int modem; + int b1; + + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return -ENXIO; + + DGAP_LOCK(bd->bd_lock, lock_flags); + + vaddr = bd->re_map_membase; + + if (!vaddr) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return -ENXIO; + } + + eaddr = (struct ev_t *) (vaddr + EVBUF); + + /* Get our head and tail */ + head = readw(&(eaddr->ev_head)); + tail = readw(&(eaddr->ev_tail)); + + /* + * Forget it if pointers out of range. + */ + + if (head >= EVMAX - EVSTART || tail >= EVMAX - EVSTART || + (head | tail) & 03) { + DPR_EVENT(("should be calling xxfail %d\n", __LINE__)); + /* Let go of board lock */ + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return -ENXIO; + } + + /* + * Loop to process all the events in the buffer. + */ + while (tail != head) { + + /* + * Get interrupt information. + */ + + event = bd->re_map_membase + tail + EVSTART; + + port = event[0]; + reason = event[1]; + modem = event[2]; + b1 = event[3]; + + DPR_EVENT(("event: jiffies: %ld port: %d reason: %x modem: %x\n", + jiffies, port, reason, modem)); + + /* + * Make sure the interrupt is valid. + */ + if (port >= bd->nasync) + goto next; + + if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA))) { + goto next; + } + + ch = bd->channels[port]; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { + goto next; + } + + /* + * If we have made it here, the event was valid. + * Lock down the channel. + */ + DGAP_LOCK(ch->ch_lock, lock_flags2); + + bs = ch->ch_bs; + + if (!bs) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + goto next; + } + + /* + * Process received data. + */ + if (reason & IFDATA) { + + /* + * ALL LOCKS *MUST* BE DROPPED BEFORE CALLING INPUT! + * input could send some data to ld, which in turn + * could do a callback to one of our other functions. + */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + dgap_input(ch); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if (ch->ch_flags & CH_RACTIVE) + ch->ch_flags |= CH_RENABLE; + else + writeb(1, &(bs->idata)); + + if (ch->ch_flags & CH_RWAIT) { + ch->ch_flags &= ~CH_RWAIT; + + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + } + + /* + * Process Modem change signals. + */ + if (reason & IFMODEM) { + ch->ch_mistat = modem; + dgap_carrier(ch); + } + + /* + * Process break. + */ + if (reason & IFBREAK) { + + DPR_EVENT(("got IFBREAK\n")); + + if (ch->ch_tun.un_tty) { + /* A break has been indicated */ + ch->ch_err_break++; + tty_buffer_request_room(ch->ch_tun.un_tty->port, 1); + tty_insert_flip_char(ch->ch_tun.un_tty->port, 0, TTY_BREAK); + tty_flip_buffer_push(ch->ch_tun.un_tty->port); + } + } + + /* + * Process Transmit low. + */ + if (reason & IFTLW) { + + DPR_EVENT(("event: got low event\n")); + + if (ch->ch_tun.un_flags & UN_LOW) { + ch->ch_tun.un_flags &= ~UN_LOW; + + if (ch->ch_tun.un_flags & UN_ISOPEN) { + if ((ch->ch_tun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + + DPR_EVENT(("event: Got low event. jiffies: %lu\n", jiffies)); + } + } + + if (ch->ch_pun.un_flags & UN_LOW) { + ch->ch_pun.un_flags &= ~UN_LOW; + if (ch->ch_pun.un_flags & UN_ISOPEN) { + if ((ch->ch_pun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + } + + if (ch->ch_flags & CH_WLOW) { + ch->ch_flags &= ~CH_WLOW; + wake_up_interruptible(&ch->ch_flags_wait); + } + } + + /* + * Process Transmit empty. + */ + if (reason & IFTEM) { + DPR_EVENT(("event: got empty event\n")); + + if (ch->ch_tun.un_flags & UN_EMPTY) { + ch->ch_tun.un_flags &= ~UN_EMPTY; + if (ch->ch_tun.un_flags & UN_ISOPEN) { + if ((ch->ch_tun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + } + + if (ch->ch_pun.un_flags & UN_EMPTY) { + ch->ch_pun.un_flags &= ~UN_EMPTY; + if (ch->ch_pun.un_flags & UN_ISOPEN) { + if ((ch->ch_pun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + } + + + if (ch->ch_flags & CH_WEMPTY) { + ch->ch_flags &= ~CH_WEMPTY; + wake_up_interruptible(&ch->ch_flags_wait); + } + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + +next: + tail = (tail + 4) & (EVMAX - EVSTART - 4); + } + + writew(tail, &(eaddr->ev_tail)); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + return 0; +} diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c deleted file mode 100644 index fbc8a94653ac..000000000000 --- a/drivers/staging/dgap/dgap_fep5.c +++ /dev/null @@ -1,1902 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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. - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - */ - - -#include -#include -#include -#include /* For udelay */ -#include /* For copy_from_user/copy_to_user */ -#include -#include /* For tty_schedule_flip */ -#include -#include - -#include "dgap_driver.h" -#include "dgap_pci.h" -#include "dgap_fep5.h" -#include "dgap_tty.h" -#include "dgap_conf.h" -#include "dgap_parse.h" -#include "dgap_trace.h" - -/* - * Our function prototypes - */ -static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); -static int dgap_event(struct board_t *bd); - -/* - * internal variables - */ -static uint dgap_count = 500; - - -/* - * Loads the dgap.conf config file from the user. - */ -void dgap_do_config_load(uchar __user *uaddr, int len) -{ - int orig_len = len; - char *to_addr; - uchar __user *from_addr = uaddr; - char buf[U2BSIZE]; - int n; - - to_addr = dgap_config_buf = kzalloc(len + 1, GFP_ATOMIC); - if (!dgap_config_buf) { - DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n")); - dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; - return; - } - - n = U2BSIZE; - while (len) { - - if (n > len) - n = len; - - if (copy_from_user((char *) &buf, from_addr, n) == -1 ) - return; - - /* Copy data from buffer to kernel memory */ - memcpy(to_addr, buf, n); - - /* increment counts */ - len -= n; - to_addr += n; - from_addr += n; - n = U2BSIZE; - } - - dgap_config_buf[orig_len] = '\0'; - - to_addr = dgap_config_buf; - dgap_parsefile(&to_addr, TRUE); - - DPR_INIT(("dgap_config_load() finish\n")); - - return; -} - - -int dgap_after_config_loaded(void) -{ - int i = 0; - int rc = 0; - - /* - * Register our ttys, now that we have the config loaded. - */ - for (i = 0; i < dgap_NumBoards; ++i) { - - /* - * Initialize KME waitqueues... - */ - init_waitqueue_head(&(dgap_Board[i]->kme_wait)); - - /* - * allocate flip buffer for board. - */ - dgap_Board[i]->flipbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); - dgap_Board[i]->flipflagbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); - } - - return rc; -} - - - -/*======================================================================= - * - * usertoboard - copy from user space to board space. - * - *=======================================================================*/ -static int dgap_usertoboard(struct board_t *brd, char *to_addr, char __user *from_addr, int len) -{ - char buf[U2BSIZE]; - int n = U2BSIZE; - - if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return -EFAULT; - - while (len) { - if (n > len) - n = len; - - if (copy_from_user((char *) &buf, from_addr, n) == -1 ) { - return -EFAULT; - } - - /* Copy data from buffer to card memory */ - memcpy_toio(to_addr, buf, n); - - /* increment counts */ - len -= n; - to_addr += n; - from_addr += n; - n = U2BSIZE; - } - return 0; -} - - -/* - * Copies the BIOS code from the user to the board, - * and starts the BIOS running. - */ -void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len) -{ - uchar *addr; - uint offset; - int i; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; - - DPR_INIT(("dgap_do_bios_load() start\n")); - - addr = brd->re_map_membase; - - /* - * clear POST area - */ - for (i = 0; i < 16; i++) - writeb(0, addr + POSTAREA + i); - - /* - * Download bios - */ - offset = 0x1000; - if (dgap_usertoboard(brd, addr + offset, ubios, len) == -1 ) { - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - return; - } - - writel(0x0bf00401, addr); - writel(0, (addr + 4)); - - /* Clear the reset, and change states. */ - writeb(FEPCLR, brd->re_map_port); - brd->state = WAIT_BIOS_LOAD; -} - - -/* - * Checks to see if the BIOS completed running on the card. - */ -static void dgap_do_wait_for_bios(struct board_t *brd) -{ - uchar *addr; - u16 word; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; - - addr = brd->re_map_membase; - word = readw(addr + POSTAREA); - - /* Check to see if BIOS thinks board is good. (GD). */ - if (word == *(u16 *) "GD") { - DPR_INIT(("GOT GD in memory, moving states.\n")); - brd->state = FINISHED_BIOS_LOAD; - return; - } - - /* Give up on board after too long of time taken */ - if (brd->wait_for_bios++ > 5000) { - u16 err1 = readw(addr + SEQUENCE); - u16 err2 = readw(addr + ERROR); - APR(("***WARNING*** %s failed diagnostics. Error #(%x,%x).\n", - brd->name, err1, err2)); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - } -} - - -/* - * Copies the FEP code from the user to the board, - * and starts the FEP running. - */ -void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) -{ - uchar *addr; - uint offset; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; - - addr = brd->re_map_membase; - - DPR_INIT(("dgap_do_fep_load() for board %s : start\n", brd->name)); - - /* - * Download FEP - */ - offset = 0x1000; - if (dgap_usertoboard(brd, addr + offset, ufep, len) == -1 ) { - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - return; - } - - /* - * If board is a concentrator product, we need to give - * it its config string describing how the concentrators look. - */ - if ((brd->type == PCX) || (brd->type == PEPC)) { - uchar string[100]; - uchar *config, *xconfig; - int i = 0; - - xconfig = dgap_create_config_string(brd, string); - - /* Write string to board memory */ - config = addr + CONFIG; - for (; i < CONFIGSIZE; i++, config++, xconfig++) { - writeb(*xconfig, config); - if ((*xconfig & 0xff) == 0xff) - break; - } - } - - writel(0xbfc01004, (addr + 0xc34)); - writel(0x3, (addr + 0xc30)); - - /* change states. */ - brd->state = WAIT_FEP_LOAD; - - DPR_INIT(("dgap_do_fep_load() for board %s : finish\n", brd->name)); - -} - - -/* - * Waits for the FEP to report thats its ready for us to use. - */ -static void dgap_do_wait_for_fep(struct board_t *brd) -{ - uchar *addr; - u16 word; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; - - addr = brd->re_map_membase; - - DPR_INIT(("dgap_do_wait_for_fep() for board %s : start. addr: %p\n", brd->name, addr)); - - word = readw(addr + FEPSTAT); - - /* Check to see if FEP is up and running now. */ - if (word == *(u16 *) "OS") { - DPR_INIT(("GOT OS in memory for board %s, moving states.\n", brd->name)); - brd->state = FINISHED_FEP_LOAD; - - /* - * Check to see if the board can support FEP5+ commands. - */ - word = readw(addr + FEP5_PLUS); - if (word == *(u16 *) "5A") { - DPR_INIT(("GOT 5A in memory for board %s, board supports extended FEP5 commands.\n", brd->name)); - brd->bd_flags |= BD_FEP5PLUS; - } - - return; - } - - /* Give up on board after too long of time taken */ - if (brd->wait_for_fep++ > 5000) { - u16 err1 = readw(addr + SEQUENCE); - u16 err2 = readw(addr + ERROR); - APR(("***WARNING*** FEPOS for %s not functioning. Error #(%x,%x).\n", - brd->name, err1, err2)); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - } - - DPR_INIT(("dgap_do_wait_for_fep() for board %s : finish\n", brd->name)); -} - - -/* - * Physically forces the FEP5 card to reset itself. - */ -static void dgap_do_reset_board(struct board_t *brd) -{ - uchar check; - u32 check1; - u32 check2; - int i = 0; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase || !brd->re_map_port) { - DPR_INIT(("dgap_do_reset_board() start. bad values. brd: %p mem: %p io: %p\n", - brd, brd ? brd->re_map_membase : 0, brd ? brd->re_map_port : 0)); - return; - } - - DPR_INIT(("dgap_do_reset_board() start. io: %p\n", brd->re_map_port)); - - /* FEPRST does not vary among supported boards */ - writeb(FEPRST, brd->re_map_port); - - for (i = 0; i <= 1000; i++) { - check = readb(brd->re_map_port) & 0xe; - if (check == FEPRST) - break; - udelay(10); - - } - if (i > 1000) { - APR(("*** WARNING *** Board not resetting... Failing board.\n")); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - goto failed; - } - - /* - * Make sure there really is memory out there. - */ - writel(0xa55a3cc3, (brd->re_map_membase + LOWMEM)); - writel(0x5aa5c33c, (brd->re_map_membase + HIGHMEM)); - check1 = readl(brd->re_map_membase + LOWMEM); - check2 = readl(brd->re_map_membase + HIGHMEM); - - if ((check1 != 0xa55a3cc3) || (check2 != 0x5aa5c33c)) { - APR(("*** Warning *** No memory at %p for board.\n", brd->re_map_membase)); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - goto failed; - } - - if (brd->state != BOARD_FAILED) - brd->state = FINISHED_RESET; - -failed: - DPR_INIT(("dgap_do_reset_board() finish\n")); -} - - -/* - * Sends a concentrator image into the FEP5 board. - */ -void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) -{ - char *vaddr; - u16 offset = 0; - struct downld_t *to_dp; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; - - vaddr = brd->re_map_membase; - - offset = readw((u16 *) (vaddr + DOWNREQ)); - to_dp = (struct downld_t *) (vaddr + (int) offset); - - /* - * The image was already read into kernel space, - * we do NOT need a user space read here - */ - memcpy_toio((char *) to_dp, uaddr, sizeof(struct downld_t)); - - /* Tell card we have data for it */ - writew(0, vaddr + (DOWNREQ)); - - brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; -} - - -#define EXPANSION_ROM_SIZE (64 * 1024) -#define FEP5_ROM_MAGIC (0xFEFFFFFF) - -static void dgap_get_vpd(struct board_t *brd) -{ - u32 magic; - u32 base_offset; - u16 rom_offset; - u16 vpd_offset; - u16 image_length; - u16 i; - uchar byte1; - uchar byte2; - - /* - * Poke the magic number at the PCI Rom Address location. - * If VPD is supported, the value read from that address - * will be non-zero. - */ - magic = FEP5_ROM_MAGIC; - pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); - pci_read_config_dword(brd->pdev, PCI_ROM_ADDRESS, &magic); - - /* VPD not supported, bail */ - if (!magic) - return; - - /* - * To get to the OTPROM memory, we have to send the boards base - * address or'ed with 1 into the PCI Rom Address location. - */ - magic = brd->membase | 0x01; - pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); - pci_read_config_dword(brd->pdev, PCI_ROM_ADDRESS, &magic); - - byte1 = readb(brd->re_map_membase); - byte2 = readb(brd->re_map_membase + 1); - - /* - * If the board correctly swapped to the OTPROM memory, - * the first 2 bytes (header) should be 0x55, 0xAA - */ - if (byte1 == 0x55 && byte2 == 0xAA) { - - base_offset = 0; - - /* - * We have to run through all the OTPROM memory looking - * for the VPD offset. - */ - while (base_offset <= EXPANSION_ROM_SIZE) { - - /* - * Lots of magic numbers here. - * - * The VPD offset is located inside the ROM Data Structure. - * We also have to remember the length of each - * ROM Data Structure, so we can "hop" to the next - * entry if the VPD isn't in the current - * ROM Data Structure. - */ - rom_offset = readw(brd->re_map_membase + base_offset + 0x18); - image_length = readw(brd->re_map_membase + rom_offset + 0x10) * 512; - vpd_offset = readw(brd->re_map_membase + rom_offset + 0x08); - - /* Found the VPD entry */ - if (vpd_offset) - break; - - /* We didn't find a VPD entry, go to next ROM entry. */ - base_offset += image_length; - - byte1 = readb(brd->re_map_membase + base_offset); - byte2 = readb(brd->re_map_membase + base_offset + 1); - - /* - * If the new ROM offset doesn't have 0x55, 0xAA - * as its header, we have run out of ROM. - */ - if (byte1 != 0x55 || byte2 != 0xAA) - break; - } - - /* - * If we have a VPD offset, then mark the board - * as having a valid VPD, and copy VPDSIZE (512) bytes of - * that VPD to the buffer we have in our board structure. - */ - if (vpd_offset) { - brd->bd_flags |= BD_HAS_VPD; - for (i = 0; i < VPDSIZE; i++) - brd->vpd[i] = readb(brd->re_map_membase + vpd_offset + i); - } - } - - /* - * We MUST poke the magic number at the PCI Rom Address location again. - * This makes the card report the regular board memory back to us, - * rather than the OTPROM memory. - */ - magic = FEP5_ROM_MAGIC; - pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); -} - - -/* - * Our board poller function. - */ -void dgap_poll_tasklet(unsigned long data) -{ - struct board_t *bd = (struct board_t *) data; - ulong lock_flags; - ulong lock_flags2; - char *vaddr; - u16 head, tail; - u16 *chk_addr; - u16 check = 0; - - if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) { - APR(("dgap_poll_tasklet() - NULL or bad bd.\n")); - return; - } - - if (bd->inhibit_poller) - return; - - DGAP_LOCK(bd->bd_lock, lock_flags); - - vaddr = bd->re_map_membase; - - /* - * If board is ready, parse deeper to see if there is anything to do. - */ - if (bd->state == BOARD_READY) { - - struct ev_t *eaddr = NULL; - - if (!bd->re_map_membase) { - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return; - } - if (!bd->re_map_port) { - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return; - } - - if (!bd->nasync) { - goto out; - } - - /* - * If this is a CX or EPCX, we need to see if the firmware - * is requesting a concentrator image from us. - */ - if ((bd->type == PCX) || (bd->type == PEPC)) { - chk_addr = (u16 *) (vaddr + DOWNREQ); - check = readw(chk_addr); - /* Nonzero if FEP is requesting concentrator image. */ - if (check) { - if (bd->conc_dl_status == NO_PENDING_CONCENTRATOR_REQUESTS) - bd->conc_dl_status = NEED_CONCENTRATOR; - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - - } - } - - eaddr = (struct ev_t *) (vaddr + EVBUF); - - /* Get our head and tail */ - head = readw(&(eaddr->ev_head)); - tail = readw(&(eaddr->ev_tail)); - - /* - * If there is an event pending. Go service it. - */ - if (head != tail) { - DGAP_UNLOCK(bd->bd_lock, lock_flags); - dgap_event(bd); - DGAP_LOCK(bd->bd_lock, lock_flags); - } - -out: - /* - * If board is doing interrupts, ACK the interrupt. - */ - if (bd && bd->intr_running) { - readb(bd->re_map_port + 2); - } - - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return; - } - - /* Our state machine to get the board up and running */ - - /* Reset board */ - if (bd->state == NEED_RESET) { - - /* Get VPD info */ - dgap_get_vpd(bd); - - dgap_do_reset_board(bd); - } - - /* Move to next state */ - if (bd->state == FINISHED_RESET) { - bd->state = NEED_CONFIG; - } - - if (bd->state == NEED_CONFIG) { - /* - * Match this board to a config the user created for us. - */ - bd->bd_config = dgap_find_config(bd->type, bd->pci_bus, bd->pci_slot); - - /* - * Because the 4 port Xr products share the same PCI ID - * as the 8 port Xr products, if we receive a NULL config - * back, and this is a PAPORT8 board, retry with a - * PAPORT4 attempt as well. - */ - if (bd->type == PAPORT8 && !bd->bd_config) { - bd->bd_config = dgap_find_config(PAPORT4, bd->pci_bus, bd->pci_slot); - } - - /* - * Register the ttys (if any) into the kernel. - */ - if (bd->bd_config) { - bd->state = FINISHED_CONFIG; - } - else { - bd->state = CONFIG_NOT_FOUND; - } - } - - /* Move to next state */ - if (bd->state == FINISHED_CONFIG) { - bd->state = NEED_DEVICE_CREATION; - } - - /* Move to next state */ - if (bd->state == NEED_DEVICE_CREATION) { - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - } - - /* Move to next state */ - if (bd->state == FINISHED_DEVICE_CREATION) { - bd->state = NEED_BIOS_LOAD; - } - - /* Move to next state */ - if (bd->state == NEED_BIOS_LOAD) { - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - } - - /* Wait for BIOS to test board... */ - if (bd->state == WAIT_BIOS_LOAD) { - dgap_do_wait_for_bios(bd); - } - - /* Move to next state */ - if (bd->state == FINISHED_BIOS_LOAD) { - bd->state = NEED_FEP_LOAD; - - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - } - - /* Wait for FEP to load on board... */ - if (bd->state == WAIT_FEP_LOAD) { - dgap_do_wait_for_fep(bd); - } - - - /* Move to next state */ - if (bd->state == FINISHED_FEP_LOAD) { - - /* - * Do tty device initialization. - */ - int rc = dgap_tty_init(bd); - - if (rc < 0) { - dgap_tty_uninit(bd); - APR(("Can't init tty devices (%d)\n", rc)); - bd->state = BOARD_FAILED; - bd->dpastatus = BD_NOFEP; - } - else { - bd->state = NEED_PROC_CREATION; - - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - } - } - - /* Move to next state */ - if (bd->state == FINISHED_PROC_CREATION) { - - bd->state = BOARD_READY; - bd->dpastatus = BD_RUNNING; - - /* - * If user requested the board to run in interrupt mode, - * go and set it up on the board. - */ - if (bd->intr_used) { - writew(1, (bd->re_map_membase + ENABLE_INTR)); - /* - * Tell the board to poll the UARTS as fast as possible. - */ - writew(FEPPOLL_MIN, (bd->re_map_membase + FEPPOLL)); - bd->intr_running = 1; - } - - /* Wake up anyone waiting for board state to change to ready */ - wake_up_interruptible(&bd->state_wait); - } - - DGAP_UNLOCK(bd->bd_lock, lock_flags); -} - - -/*======================================================================= - * - * dgap_cmdb - Sends a 2 byte command to the FEP. - * - * ch - Pointer to channel structure. - * cmd - Command to be sent. - * byte1 - Integer containing first byte to be sent. - * byte2 - Integer containing second byte to be sent. - * ncmds - Wait until ncmds or fewer cmds are left - * in the cmd buffer before returning. - * - *=======================================================================*/ -void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds) -{ - char *vaddr = NULL; - struct cm_t *cm_addr = NULL; - uint count; - uint n; - u16 head; - u16 tail; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - /* - * Check if board is still alive. - */ - if (ch->ch_bd->state == BOARD_FAILED) { - DPR_CORE(("%s:%d board is in failed state.\n", __FILE__, __LINE__)); - return; - } - - /* - * Make sure the pointers are in range before - * writing to the FEP memory. - */ - vaddr = ch->ch_bd->re_map_membase; - - if (!vaddr) - return; - - cm_addr = (struct cm_t *) (vaddr + CMDBUF); - head = readw(&(cm_addr->cm_head)); - - /* - * Forget it if pointers out of range. - */ - if (head >= (CMDMAX - CMDSTART) || (head & 03)) { - DPR_CORE(("%s:%d pointers out of range, failing board!\n", __FILE__, __LINE__)); - ch->ch_bd->state = BOARD_FAILED; - return; - } - - /* - * Put the data in the circular command buffer. - */ - writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); - writeb(byte1, (char *) (vaddr + head + CMDSTART + 2)); - writeb(byte2, (char *) (vaddr + head + CMDSTART + 3)); - - head = (head + 4) & (CMDMAX - CMDSTART - 4); - - writew(head, &(cm_addr->cm_head)); - - /* - * Wait if necessary before updating the head - * pointer to limit the number of outstanding - * commands to the FEP. If the time spent waiting - * is outlandish, declare the FEP dead. - */ - for (count = dgap_count ;;) { - - head = readw(&(cm_addr->cm_head)); - tail = readw(&(cm_addr->cm_tail)); - - n = (head - tail) & (CMDMAX - CMDSTART - 4); - - if (n <= ncmds * sizeof(struct cm_t)) - break; - - if (--count == 0) { - DPR_CORE(("%s:%d failing board.\n",__FILE__, __LINE__)); - ch->ch_bd->state = BOARD_FAILED; - return; - } - udelay(10); - } -} - - -/*======================================================================= - * - * dgap_cmdw - Sends a 1 word command to the FEP. - * - * ch - Pointer to channel structure. - * cmd - Command to be sent. - * word - Integer containing word to be sent. - * ncmds - Wait until ncmds or fewer cmds are left - * in the cmd buffer before returning. - * - *=======================================================================*/ -void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) -{ - char *vaddr = NULL; - struct cm_t *cm_addr = NULL; - uint count; - uint n; - u16 head; - u16 tail; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - /* - * Check if board is still alive. - */ - if (ch->ch_bd->state == BOARD_FAILED) { - DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__)); - return; - } - - /* - * Make sure the pointers are in range before - * writing to the FEP memory. - */ - vaddr = ch->ch_bd->re_map_membase; - if (!vaddr) - return; - - cm_addr = (struct cm_t *) (vaddr + CMDBUF); - head = readw(&(cm_addr->cm_head)); - - /* - * Forget it if pointers out of range. - */ - if (head >= (CMDMAX - CMDSTART) || (head & 03)) { - DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__)); - ch->ch_bd->state = BOARD_FAILED; - return; - } - - /* - * Put the data in the circular command buffer. - */ - writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); - writew((u16) word, (char *) (vaddr + head + CMDSTART + 2)); - - head = (head + 4) & (CMDMAX - CMDSTART - 4); - - writew(head, &(cm_addr->cm_head)); - - /* - * Wait if necessary before updating the head - * pointer to limit the number of outstanding - * commands to the FEP. If the time spent waiting - * is outlandish, declare the FEP dead. - */ - for (count = dgap_count ;;) { - - head = readw(&(cm_addr->cm_head)); - tail = readw(&(cm_addr->cm_tail)); - - n = (head - tail) & (CMDMAX - CMDSTART - 4); - - if (n <= ncmds * sizeof(struct cm_t)) - break; - - if (--count == 0) { - DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__)); - ch->ch_bd->state = BOARD_FAILED; - return; - } - udelay(10); - } -} - - - -/*======================================================================= - * - * dgap_cmdw_ext - Sends a extended word command to the FEP. - * - * ch - Pointer to channel structure. - * cmd - Command to be sent. - * word - Integer containing word to be sent. - * ncmds - Wait until ncmds or fewer cmds are left - * in the cmd buffer before returning. - * - *=======================================================================*/ -static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) -{ - char *vaddr = NULL; - struct cm_t *cm_addr = NULL; - uint count; - uint n; - u16 head; - u16 tail; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - /* - * Check if board is still alive. - */ - if (ch->ch_bd->state == BOARD_FAILED) { - DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__)); - return; - } - - /* - * Make sure the pointers are in range before - * writing to the FEP memory. - */ - vaddr = ch->ch_bd->re_map_membase; - if (!vaddr) - return; - - cm_addr = (struct cm_t *) (vaddr + CMDBUF); - head = readw(&(cm_addr->cm_head)); - - /* - * Forget it if pointers out of range. - */ - if (head >= (CMDMAX - CMDSTART) || (head & 03)) { - DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__)); - ch->ch_bd->state = BOARD_FAILED; - return; - } - - /* - * Put the data in the circular command buffer. - */ - - /* Write an FF to tell the FEP that we want an extended command */ - writeb((uchar) 0xff, (char *) (vaddr + head + CMDSTART + 0)); - - writeb((uchar) ch->ch_portnum, (uchar *) (vaddr + head + CMDSTART + 1)); - writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2)); - - /* - * If the second part of the command won't fit, - * put it at the beginning of the circular buffer. - */ - if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03))) { - writew((u16) word, (char *) (vaddr + CMDSTART)); - } else { - writew((u16) word, (char *) (vaddr + head + CMDSTART + 4)); - } - - head = (head + 8) & (CMDMAX - CMDSTART - 4); - - writew(head, &(cm_addr->cm_head)); - - /* - * Wait if necessary before updating the head - * pointer to limit the number of outstanding - * commands to the FEP. If the time spent waiting - * is outlandish, declare the FEP dead. - */ - for (count = dgap_count ;;) { - - head = readw(&(cm_addr->cm_head)); - tail = readw(&(cm_addr->cm_tail)); - - n = (head - tail) & (CMDMAX - CMDSTART - 4); - - if (n <= ncmds * sizeof(struct cm_t)) - break; - - if (--count == 0) { - DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__)); - ch->ch_bd->state = BOARD_FAILED; - return; - } - udelay(10); - } -} - - -/*======================================================================= - * - * dgap_wmove - Write data to FEP buffer. - * - * ch - Pointer to channel structure. - * buf - Poiter to characters to be moved. - * cnt - Number of characters to move. - * - *=======================================================================*/ -void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) -{ - int n; - char *taddr; - struct bs_t *bs; - u16 head; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - /* - * Check parameters. - */ - bs = ch->ch_bs; - head = readw(&(bs->tx_head)); - - /* - * If pointers are out of range, just return. - */ - if ((cnt > ch->ch_tsize) || (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize) { - DPR_CORE(("%s:%d pointer out of range", __FILE__, __LINE__)); - return; - } - - /* - * If the write wraps over the top of the circular buffer, - * move the portion up to the wrap point, and reset the - * pointers to the bottom. - */ - n = ch->ch_tstart + ch->ch_tsize - head; - - if (cnt >= n) { - cnt -= n; - taddr = ch->ch_taddr + head; - memcpy_toio(taddr, buf, n); - head = ch->ch_tstart; - buf += n; - } - - /* - * Move rest of data. - */ - taddr = ch->ch_taddr + head; - n = cnt; - memcpy_toio(taddr, buf, n); - head += cnt; - - writew(head, &(bs->tx_head)); -} - -/* - * Retrives the current custom baud rate from FEP memory, - * and returns it back to the user. - * Returns 0 on error. - */ -uint dgap_get_custom_baud(struct channel_t *ch) -{ - uchar *vaddr; - ulong offset = 0; - uint value = 0; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { - return 0; - } - - if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC) { - return 0; - } - - if (!(ch->ch_bd->bd_flags & BD_FEP5PLUS)) - return 0; - - vaddr = ch->ch_bd->re_map_membase; - - if (!vaddr) - return 0; - - /* - * Go get from fep mem, what the fep - * believes the custom baud rate is. - */ - offset = ((((*(unsigned short *)(vaddr + ECS_SEG)) << 4) + - (ch->ch_portnum * 0x28) + LINE_SPEED)); - - value = readw(vaddr + offset); - return value; -} - - -/* - * Calls the firmware to reset this channel. - */ -void dgap_firmware_reset_port(struct channel_t *ch) -{ - dgap_cmdb(ch, CHRESET, 0, 0, 0); - - /* - * Now that the channel is reset, we need to make sure - * all the current settings get reapplied to the port - * in the firmware. - * - * So we will set the driver's cache of firmware - * settings all to 0, and then call param. - */ - ch->ch_fepiflag = 0; - ch->ch_fepcflag = 0; - ch->ch_fepoflag = 0; - ch->ch_fepstartc = 0; - ch->ch_fepstopc = 0; - ch->ch_fepastartc = 0; - ch->ch_fepastopc = 0; - ch->ch_mostat = 0; - ch->ch_hflow = 0; -} - - -/*======================================================================= - * - * dgap_param - Set Digi parameters. - * - * struct tty_struct * - TTY for port. - * - *=======================================================================*/ -int dgap_param(struct tty_struct *tty) -{ - struct ktermios *ts; - struct board_t *bd; - struct channel_t *ch; - struct bs_t *bs; - struct un_t *un; - u16 head; - u16 cflag; - u16 iflag; - uchar mval; - uchar hflow; - - if (!tty || tty->magic != TTY_MAGIC) - return -ENXIO; - - un = (struct un_t *) tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -ENXIO; - - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -ENXIO; - - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -ENXIO; - - bs = ch->ch_bs; - if (!bs) - return -ENXIO; - - DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", - ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); - - ts = &tty->termios; - - /* - * If baud rate is zero, flush queues, and set mval to drop DTR. - */ - if ((ch->ch_c_cflag & (CBAUD)) == 0) { - - /* flush rx */ - head = readw(&(ch->ch_bs->rx_head)); - writew(head, &(ch->ch_bs->rx_tail)); - - /* flush tx */ - head = readw(&(ch->ch_bs->tx_head)); - writew(head, &(ch->ch_bs->tx_tail)); - - ch->ch_flags |= (CH_BAUD0); - - /* Drop RTS and DTR */ - ch->ch_mval &= ~(D_RTS(ch)|D_DTR(ch)); - mval = D_DTR(ch) | D_RTS(ch); - ch->ch_baud_info = 0; - - } else if (ch->ch_custom_speed && (bd->bd_flags & BD_FEP5PLUS)) { - /* - * Tell the fep to do the command - */ - - DPR_PARAM(("param: Want %d speed\n", ch->ch_custom_speed)); - - dgap_cmdw_ext(ch, 0xff01, ch->ch_custom_speed, 0); - - /* - * Now go get from fep mem, what the fep - * believes the custom baud rate is. - */ - ch->ch_baud_info = ch->ch_custom_speed = dgap_get_custom_baud(ch); - - DPR_PARAM(("param: Got %d speed\n", ch->ch_custom_speed)); - - /* Handle transition from B0 */ - if (ch->ch_flags & CH_BAUD0) { - ch->ch_flags &= ~(CH_BAUD0); - ch->ch_mval |= (D_RTS(ch)|D_DTR(ch)); - } - mval = D_DTR(ch) | D_RTS(ch); - - } else { - /* - * Set baud rate, character size, and parity. - */ - - - int iindex = 0; - int jindex = 0; - int baud = 0; - - ulong bauds[4][16] = { - { /* slowbaud */ - 0, 50, 75, 110, - 134, 150, 200, 300, - 600, 1200, 1800, 2400, - 4800, 9600, 19200, 38400 }, - { /* slowbaud & CBAUDEX */ - 0, 57600, 115200, 230400, - 460800, 150, 200, 921600, - 600, 1200, 1800, 2400, - 4800, 9600, 19200, 38400 }, - { /* fastbaud */ - 0, 57600, 76800, 115200, - 14400, 57600, 230400, 76800, - 115200, 230400, 28800, 460800, - 921600, 9600, 19200, 38400 }, - { /* fastbaud & CBAUDEX */ - 0, 57600, 115200, 230400, - 460800, 150, 200, 921600, - 600, 1200, 1800, 2400, - 4800, 9600, 19200, 38400 } - }; - - /* Only use the TXPrint baud rate if the terminal unit is NOT open */ - if (!(ch->ch_tun.un_flags & UN_ISOPEN) && (un->un_type == DGAP_PRINT)) - baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; - else - baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; - - if (ch->ch_c_cflag & CBAUDEX) - iindex = 1; - - if (ch->ch_digi.digi_flags & DIGI_FAST) - iindex += 2; - - jindex = baud; - - if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { - baud = bauds[iindex][jindex]; - } else { - DPR_IOCTL(("baud indices were out of range (%d)(%d)", - iindex, jindex)); - baud = 0; - } - - if (baud == 0) - baud = 9600; - - ch->ch_baud_info = baud; - - - /* - * CBAUD has bit position 0x1000 set these days to indicate Linux - * baud rate remap. - * We use a different bit assignment for high speed. Clear this - * bit out while grabbing the parts of "cflag" we want. - */ - cflag = ch->ch_c_cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); - - /* - * HUPCL bit is used by FEP to indicate fast baud - * table is to be used. - */ - if ((ch->ch_digi.digi_flags & DIGI_FAST) || (ch->ch_c_cflag & CBAUDEX)) - cflag |= HUPCL; - - - if ((ch->ch_c_cflag & CBAUDEX) && !(ch->ch_digi.digi_flags & DIGI_FAST)) { - /* - * The below code is trying to guarantee that only baud rates - * 115200, 230400, 460800, 921600 are remapped. We use exclusive or - * because the various baud rates share common bit positions - * and therefore can't be tested for easily. - */ - tcflag_t tcflag = (ch->ch_c_cflag & CBAUD) | CBAUDEX; - int baudpart = 0; - - /* Map high speed requests to index into FEP's baud table */ - switch (tcflag) { - case B57600 : - baudpart = 1; - break; -#ifdef B76800 - case B76800 : - baudpart = 2; - break; -#endif - case B115200 : - baudpart = 3; - break; - case B230400 : - baudpart = 9; - break; - case B460800 : - baudpart = 11; - break; -#ifdef B921600 - case B921600 : - baudpart = 12; - break; -#endif - default: - baudpart = 0; - } - - if (baudpart) - cflag = (cflag & ~(CBAUD | CBAUDEX)) | baudpart; - } - - cflag &= 0xffff; - - if (cflag != ch->ch_fepcflag) { - ch->ch_fepcflag = (u16) (cflag & 0xffff); - - /* Okay to have channel and board locks held calling this */ - dgap_cmdw(ch, SCFLAG, (u16) cflag, 0); - } - - /* Handle transition from B0 */ - if (ch->ch_flags & CH_BAUD0) { - ch->ch_flags &= ~(CH_BAUD0); - ch->ch_mval |= (D_RTS(ch)|D_DTR(ch)); - } - mval = D_DTR(ch) | D_RTS(ch); - } - - /* - * Get input flags. - */ - iflag = ch->ch_c_iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | IXON | IXANY | IXOFF); - - if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) { - iflag &= ~(IXON | IXOFF); - ch->ch_c_iflag &= ~(IXON | IXOFF); - } - - /* - * Only the IBM Xr card can switch between - * 232 and 422 modes on the fly - */ - if (bd->device == PCI_DEVICE_XR_IBM_DID) { - if (ch->ch_digi.digi_flags & DIGI_422) - dgap_cmdb(ch, SCOMMODE, MODE_422, 0, 0); - else - dgap_cmdb(ch, SCOMMODE, MODE_232, 0, 0); - } - - if (ch->ch_digi.digi_flags & DIGI_ALTPIN) - iflag |= IALTPIN ; - - if (iflag != ch->ch_fepiflag) { - ch->ch_fepiflag = iflag; - - /* Okay to have channel and board locks held calling this */ - dgap_cmdw(ch, SIFLAG, (u16) ch->ch_fepiflag, 0); - } - - /* - * Select hardware handshaking. - */ - hflow = 0; - - if (ch->ch_c_cflag & CRTSCTS) { - hflow |= (D_RTS(ch) | D_CTS(ch)); - } - if (ch->ch_digi.digi_flags & RTSPACE) - hflow |= D_RTS(ch); - if (ch->ch_digi.digi_flags & DTRPACE) - hflow |= D_DTR(ch); - if (ch->ch_digi.digi_flags & CTSPACE) - hflow |= D_CTS(ch); - if (ch->ch_digi.digi_flags & DSRPACE) - hflow |= D_DSR(ch); - if (ch->ch_digi.digi_flags & DCDPACE) - hflow |= D_CD(ch); - - if (hflow != ch->ch_hflow) { - ch->ch_hflow = hflow; - - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SHFLOW, (uchar) hflow, 0xff, 0); - } - - - /* - * Set RTS and/or DTR Toggle if needed, but only if product is FEP5+ based. - */ - if (bd->bd_flags & BD_FEP5PLUS) { - u16 hflow2 = 0; - if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { - hflow2 |= (D_RTS(ch)); - } - if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { - hflow2 |= (D_DTR(ch)); - } - - dgap_cmdw_ext(ch, 0xff03, hflow2, 0); - } - - /* - * Set modem control lines. - */ - - mval ^= ch->ch_mforce & (mval ^ ch->ch_mval); - - DPR_PARAM(("dgap_param: mval: %x ch_mforce: %x ch_mval: %x ch_mostat: %x\n", - mval, ch->ch_mforce, ch->ch_mval, ch->ch_mostat)); - - if (ch->ch_mostat ^ mval) { - ch->ch_mostat = mval; - - /* Okay to have channel and board locks held calling this */ - DPR_PARAM(("dgap_param: Sending SMODEM mval: %x\n", mval)); - dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0); - } - - /* - * Read modem signals, and then call carrier function. - */ - ch->ch_mistat = readb(&(bs->m_stat)); - dgap_carrier(ch); - - /* - * Set the start and stop characters. - */ - if (ch->ch_startc != ch->ch_fepstartc || ch->ch_stopc != ch->ch_fepstopc) { - ch->ch_fepstartc = ch->ch_startc; - ch->ch_fepstopc = ch->ch_stopc; - - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SFLOWC, ch->ch_fepstartc, ch->ch_fepstopc, 0); - } - - /* - * Set the Auxiliary start and stop characters. - */ - if (ch->ch_astartc != ch->ch_fepastartc || ch->ch_astopc != ch->ch_fepastopc) { - ch->ch_fepastartc = ch->ch_astartc; - ch->ch_fepastopc = ch->ch_astopc; - - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SAFLOWC, ch->ch_fepastartc, ch->ch_fepastopc, 0); - } - - DPR_PARAM(("param finish\n")); - - return 0; -} - - -/* - * dgap_parity_scan() - * - * Convert the FEP5 way of reporting parity errors and breaks into - * the Linux line discipline way. - */ -void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len) -{ - int l = *len; - int count = 0; - unsigned char *in, *cout, *fout; - unsigned char c; - - in = cbuf; - cout = cbuf; - fout = fbuf; - - DPR_PSCAN(("dgap_parity_scan start\n")); - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; - - while (l--) { - c = *in++; - switch (ch->pscan_state) { - default: - /* reset to sanity and fall through */ - ch->pscan_state = 0; - - case 0: - /* No FF seen yet */ - if (c == (unsigned char) '\377') { - /* delete this character from stream */ - ch->pscan_state = 1; - } else { - *cout++ = c; - *fout++ = TTY_NORMAL; - count += 1; - } - break; - - case 1: - /* first FF seen */ - if (c == (unsigned char) '\377') { - /* doubled ff, transform to single ff */ - *cout++ = c; - *fout++ = TTY_NORMAL; - count += 1; - ch->pscan_state = 0; - } else { - /* save value examination in next state */ - ch->pscan_savechar = c; - ch->pscan_state = 2; - } - break; - - case 2: - /* third character of ff sequence */ - - *cout++ = c; - - if (ch->pscan_savechar == 0x0) { - - if (c == 0x0) { - DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting break.\n", c)); - ch->ch_err_break++; - *fout++ = TTY_BREAK; - } - else { - DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting parity.\n", c)); - ch->ch_err_parity++; - *fout++ = TTY_PARITY; - } - } - else { - DPR_PSCAN(("%s:%d Logic Error.\n", __FILE__, __LINE__)); - } - - count += 1; - ch->pscan_state = 0; - } - } - *len = count; - DPR_PSCAN(("dgap_parity_scan finish\n")); -} - - - - -/*======================================================================= - * - * dgap_event - FEP to host event processing routine. - * - * bd - Board of current event. - * - *=======================================================================*/ -static int dgap_event(struct board_t *bd) -{ - struct channel_t *ch; - ulong lock_flags; - ulong lock_flags2; - struct bs_t *bs; - uchar *event; - uchar *vaddr = NULL; - struct ev_t *eaddr = NULL; - uint head; - uint tail; - int port; - int reason; - int modem; - int b1; - - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -ENXIO; - - DGAP_LOCK(bd->bd_lock, lock_flags); - - vaddr = bd->re_map_membase; - - if (!vaddr) { - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return -ENXIO; - } - - eaddr = (struct ev_t *) (vaddr + EVBUF); - - /* Get our head and tail */ - head = readw(&(eaddr->ev_head)); - tail = readw(&(eaddr->ev_tail)); - - /* - * Forget it if pointers out of range. - */ - - if (head >= EVMAX - EVSTART || tail >= EVMAX - EVSTART || - (head | tail) & 03) { - DPR_EVENT(("should be calling xxfail %d\n", __LINE__)); - /* Let go of board lock */ - DGAP_UNLOCK(bd->bd_lock, lock_flags); - return -ENXIO; - } - - /* - * Loop to process all the events in the buffer. - */ - while (tail != head) { - - /* - * Get interrupt information. - */ - - event = bd->re_map_membase + tail + EVSTART; - - port = event[0]; - reason = event[1]; - modem = event[2]; - b1 = event[3]; - - DPR_EVENT(("event: jiffies: %ld port: %d reason: %x modem: %x\n", - jiffies, port, reason, modem)); - - /* - * Make sure the interrupt is valid. - */ - if (port >= bd->nasync) - goto next; - - if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA))) { - goto next; - } - - ch = bd->channels[port]; - - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { - goto next; - } - - /* - * If we have made it here, the event was valid. - * Lock down the channel. - */ - DGAP_LOCK(ch->ch_lock, lock_flags2); - - bs = ch->ch_bs; - - if (!bs) { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - goto next; - } - - /* - * Process received data. - */ - if (reason & IFDATA) { - - /* - * ALL LOCKS *MUST* BE DROPPED BEFORE CALLING INPUT! - * input could send some data to ld, which in turn - * could do a callback to one of our other functions. - */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - dgap_input(ch); - - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - - if (ch->ch_flags & CH_RACTIVE) - ch->ch_flags |= CH_RENABLE; - else - writeb(1, &(bs->idata)); - - if (ch->ch_flags & CH_RWAIT) { - ch->ch_flags &= ~CH_RWAIT; - - wake_up_interruptible(&ch->ch_tun.un_flags_wait); - } - } - - /* - * Process Modem change signals. - */ - if (reason & IFMODEM) { - ch->ch_mistat = modem; - dgap_carrier(ch); - } - - /* - * Process break. - */ - if (reason & IFBREAK) { - - DPR_EVENT(("got IFBREAK\n")); - - if (ch->ch_tun.un_tty) { - /* A break has been indicated */ - ch->ch_err_break++; - tty_buffer_request_room(ch->ch_tun.un_tty->port, 1); - tty_insert_flip_char(ch->ch_tun.un_tty->port, 0, TTY_BREAK); - tty_flip_buffer_push(ch->ch_tun.un_tty->port); - } - } - - /* - * Process Transmit low. - */ - if (reason & IFTLW) { - - DPR_EVENT(("event: got low event\n")); - - if (ch->ch_tun.un_flags & UN_LOW) { - ch->ch_tun.un_flags &= ~UN_LOW; - - if (ch->ch_tun.un_flags & UN_ISOPEN) { - if ((ch->ch_tun.un_tty->flags & - (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_tun.un_tty->ldisc->ops->write_wakeup) - { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - } - wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); - wake_up_interruptible(&ch->ch_tun.un_flags_wait); - - DPR_EVENT(("event: Got low event. jiffies: %lu\n", jiffies)); - } - } - - if (ch->ch_pun.un_flags & UN_LOW) { - ch->ch_pun.un_flags &= ~UN_LOW; - if (ch->ch_pun.un_flags & UN_ISOPEN) { - if ((ch->ch_pun.un_tty->flags & - (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_pun.un_tty->ldisc->ops->write_wakeup) - { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - } - wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); - wake_up_interruptible(&ch->ch_pun.un_flags_wait); - } - } - - if (ch->ch_flags & CH_WLOW) { - ch->ch_flags &= ~CH_WLOW; - wake_up_interruptible(&ch->ch_flags_wait); - } - } - - /* - * Process Transmit empty. - */ - if (reason & IFTEM) { - DPR_EVENT(("event: got empty event\n")); - - if (ch->ch_tun.un_flags & UN_EMPTY) { - ch->ch_tun.un_flags &= ~UN_EMPTY; - if (ch->ch_tun.un_flags & UN_ISOPEN) { - if ((ch->ch_tun.un_tty->flags & - (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_tun.un_tty->ldisc->ops->write_wakeup) - { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - } - wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); - wake_up_interruptible(&ch->ch_tun.un_flags_wait); - } - } - - if (ch->ch_pun.un_flags & UN_EMPTY) { - ch->ch_pun.un_flags &= ~UN_EMPTY; - if (ch->ch_pun.un_flags & UN_ISOPEN) { - if ((ch->ch_pun.un_tty->flags & - (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_pun.un_tty->ldisc->ops->write_wakeup) - { - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); - DGAP_LOCK(bd->bd_lock, lock_flags); - DGAP_LOCK(ch->ch_lock, lock_flags2); - } - wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); - wake_up_interruptible(&ch->ch_pun.un_flags_wait); - } - } - - - if (ch->ch_flags & CH_WEMPTY) { - ch->ch_flags &= ~CH_WEMPTY; - wake_up_interruptible(&ch->ch_flags_wait); - } - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - -next: - tail = (tail + 4) & (EVMAX - EVSTART - 4); - } - - writew(tail, &(eaddr->ev_tail)); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - return 0; -} From 7568f7d3ef19b9826abdf404f0a2be5c58ea1583 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:01 -0500 Subject: [PATCH 0437/1375] staging: dgap: Merge dgap_sysfs.c into dgap_driver.c There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 3 +- drivers/staging/dgap/dgap_driver.c | 749 +++++++++++++++++++++++++++ drivers/staging/dgap/dgap_sysfs.c | 792 ----------------------------- 3 files changed, 750 insertions(+), 794 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_sysfs.c diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index 867b1e5d6fcb..f5c9e357f500 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -2,6 +2,5 @@ obj-$(CONFIG_DGAP) += dgap.o dgap-objs := dgap_driver.o \ - dgap_parse.o dgap_trace.o \ - dgap_sysfs.o + dgap_parse.o dgap_trace.o diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index db4da9a26092..93b72d376ce8 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -45,6 +45,10 @@ #include #include /* For read[bwl]/write[bwl] */ +#include +#include +#include + #include "dgap_driver.h" #include "dgap_pci.h" #include "dgap_fep5.h" @@ -6379,3 +6383,748 @@ next: return 0; } + +static ssize_t dgap_driver_version_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART); +} +static DRIVER_ATTR(version, S_IRUSR, dgap_driver_version_show, NULL); + + +static ssize_t dgap_driver_boards_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", dgap_NumBoards); +} +static DRIVER_ATTR(boards, S_IRUSR, dgap_driver_boards_show, NULL); + + +static ssize_t dgap_driver_maxboards_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS); +} +static DRIVER_ATTR(maxboards, S_IRUSR, dgap_driver_maxboards_show, NULL); + + +static ssize_t dgap_driver_pollcounter_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%ld\n", dgap_poll_counter); +} +static DRIVER_ATTR(pollcounter, S_IRUSR, dgap_driver_pollcounter_show, NULL); + + +static ssize_t dgap_driver_state_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", dgap_driver_state_text[dgap_driver_state]); +} +static DRIVER_ATTR(state, S_IRUSR, dgap_driver_state_show, NULL); + + +static ssize_t dgap_driver_debug_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_debug); +} + +static ssize_t dgap_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "0x%x\n", &dgap_debug); + return count; +} +static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgap_driver_debug_show, dgap_driver_debug_store); + + +static ssize_t dgap_driver_rawreadok_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_rawreadok); +} + +static ssize_t dgap_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "0x%x\n", &dgap_rawreadok); + return count; +} +static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgap_driver_rawreadok_show, dgap_driver_rawreadok_store); + + +static ssize_t dgap_driver_pollrate_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%dms\n", dgap_poll_tick); +} + +static ssize_t dgap_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "%d\n", &dgap_poll_tick); + return count; +} +static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, dgap_driver_pollrate_store); + + +void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) +{ + int rc = 0; + struct device_driver *driverfs = &dgap_driver->driver; + + rc |= driver_create_file(driverfs, &driver_attr_version); + rc |= driver_create_file(driverfs, &driver_attr_boards); + rc |= driver_create_file(driverfs, &driver_attr_maxboards); + rc |= driver_create_file(driverfs, &driver_attr_debug); + rc |= driver_create_file(driverfs, &driver_attr_rawreadok); + rc |= driver_create_file(driverfs, &driver_attr_pollrate); + rc |= driver_create_file(driverfs, &driver_attr_pollcounter); + rc |= driver_create_file(driverfs, &driver_attr_state); + if (rc) { + printk(KERN_ERR "DGAP: sysfs driver_create_file failed!\n"); + } +} + + +void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver) +{ + struct device_driver *driverfs = &dgap_driver->driver; + driver_remove_file(driverfs, &driver_attr_version); + driver_remove_file(driverfs, &driver_attr_boards); + driver_remove_file(driverfs, &driver_attr_maxboards); + driver_remove_file(driverfs, &driver_attr_debug); + driver_remove_file(driverfs, &driver_attr_rawreadok); + driver_remove_file(driverfs, &driver_attr_pollrate); + driver_remove_file(driverfs, &driver_attr_pollcounter); + driver_remove_file(driverfs, &driver_attr_state); +} + + +#define DGAP_VERIFY_BOARD(p, bd) \ + if (!p) \ + return (0); \ + \ + bd = dev_get_drvdata(p); \ + if (!bd || bd->magic != DGAP_BOARD_MAGIC) \ + return (0); \ + if (bd->state != BOARD_READY) \ + return (0); \ + + +static ssize_t dgap_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %s\n", bd->channels[i]->ch_portnum, + bd->channels[i]->ch_open_count ? "Open" : "Closed"); + } + return count; +} +static DEVICE_ATTR(ports_state, S_IRUSR, dgap_ports_state_show, NULL); + + +static ssize_t dgap_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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_baud_info); + } + return count; +} +static DEVICE_ATTR(ports_baud, S_IRUSR, dgap_ports_baud_show, NULL); + + +static ssize_t dgap_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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, + (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" : "", + (bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "", + (bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "", + (bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : ""); + } else { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d\n", bd->channels[i]->ch_portnum); + } + } + return count; +} +static DEVICE_ATTR(ports_msignals, S_IRUSR, dgap_ports_msignals_show, NULL); + + +static ssize_t dgap_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_iflag, S_IRUSR, dgap_ports_iflag_show, NULL); + + +static ssize_t dgap_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_cflag, S_IRUSR, dgap_ports_cflag_show, NULL); + + +static ssize_t dgap_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_oflag, S_IRUSR, dgap_ports_oflag_show, NULL); + + +static ssize_t dgap_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_lflag, S_IRUSR, dgap_ports_lflag_show, NULL); + + +static ssize_t dgap_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgap_ports_digi_flag_show, NULL); + + +static ssize_t dgap_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgap_ports_rxcount_show, NULL); + + +static ssize_t dgap_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + 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); + } + return count; +} +static DEVICE_ATTR(ports_txcount, S_IRUSR, dgap_ports_txcount_show, NULL); + + +/* this function creates the sys files that will export each signal status + * to sysfs each value will be put in a separate filename + */ +void dgap_create_ports_sysfiles(struct board_t *bd) +{ + int rc = 0; + + dev_set_drvdata(&bd->pdev->dev, bd); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); + if (rc) { + printk(KERN_ERR "DGAP: sysfs device_create_file failed!\n"); + } +} + + +/* removes all the sys files created for that port */ +void dgap_remove_ports_sysfiles(struct board_t *bd) +{ + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount); +} + + +static ssize_t dgap_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); +} +static DEVICE_ATTR(state, S_IRUSR, dgap_tty_state_show, NULL); + + +static ssize_t dgap_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_baud_info); +} +static DEVICE_ATTR(baud, S_IRUSR, dgap_tty_baud_show, NULL); + + +static ssize_t dgap_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + if (ch->ch_open_count) { + return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n", + (ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "", + (ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "", + (ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "", + (ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "", + (ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "", + (ch->ch_mistat & UART_MSR_RI) ? "RI" : ""); + } + return 0; +} +static DEVICE_ATTR(msignals, S_IRUSR, dgap_tty_msignals_show, NULL); + + +static ssize_t dgap_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag); +} +static DEVICE_ATTR(iflag, S_IRUSR, dgap_tty_iflag_show, NULL); + + +static ssize_t dgap_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag); +} +static DEVICE_ATTR(cflag, S_IRUSR, dgap_tty_cflag_show, NULL); + + +static ssize_t dgap_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag); +} +static DEVICE_ATTR(oflag, S_IRUSR, dgap_tty_oflag_show, NULL); + + +static ssize_t dgap_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag); +} +static DEVICE_ATTR(lflag, S_IRUSR, dgap_tty_lflag_show, NULL); + + +static ssize_t dgap_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags); +} +static DEVICE_ATTR(digi_flag, S_IRUSR, dgap_tty_digi_flag_show, NULL); + + +static ssize_t dgap_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); +} +static DEVICE_ATTR(rxcount, S_IRUSR, dgap_tty_rxcount_show, NULL); + + +static ssize_t dgap_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); +} +static DEVICE_ATTR(txcount, S_IRUSR, dgap_tty_txcount_show, NULL); + + +static ssize_t dgap_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int cn; + int bn; + struct cnode *cptr = NULL; + int found = FALSE; + int ncount = 0; + int starto = 0; + int i = 0; + + if (!d) + return (0); + un = dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + bn = bd->boardnum; + cn = ch->ch_portnum; + + for (cptr = bd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + if (cptr->u.board.v_start) + starto = cptr->u.board.start; + else + starto = 1; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + + for (i = 0; i < dgap_config_get_number_of_ports(bd); i++) { + if (cn == i) { + return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", + ptr1, i + starto); + } + } + } + + if (cptr->type == CNODE) { + + for (i = 0; i < cptr->u.conc.nport; i++) { + if (cn == (i + ncount)) { + + return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", + cptr->u.conc.id, + i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); + } + } + + ncount += cptr->u.conc.nport; + } + + if (cptr->type == MNODE) { + + for (i = 0; i < cptr->u.module.nport; i++) { + if (cn == (i + ncount)) { + return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", + cptr->u.module.id, + i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); + } + } + + ncount += cptr->u.module.nport; + + } + } + + return snprintf(buf, PAGE_SIZE, "%s_dgap_%d_%d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", bn, cn); + +} +static DEVICE_ATTR(custom_name, S_IRUSR, dgap_tty_name_show, NULL); + + +static struct attribute *dgap_sysfs_tty_entries[] = { + &dev_attr_state.attr, + &dev_attr_baud.attr, + &dev_attr_msignals.attr, + &dev_attr_iflag.attr, + &dev_attr_cflag.attr, + &dev_attr_oflag.attr, + &dev_attr_lflag.attr, + &dev_attr_digi_flag.attr, + &dev_attr_rxcount.attr, + &dev_attr_txcount.attr, + &dev_attr_custom_name.attr, + NULL +}; + + +static struct attribute_group dgap_tty_attribute_group = { + .name = NULL, + .attrs = dgap_sysfs_tty_entries, +}; + + + + +void dgap_create_tty_sysfs(struct un_t *un, struct device *c) +{ + int ret; + + ret = sysfs_create_group(&c->kobj, &dgap_tty_attribute_group); + if (ret) { + printk(KERN_ERR "dgap: failed to create sysfs tty device attributes.\n"); + sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); + return; + } + + dev_set_drvdata(c, un); + +} + + +void dgap_remove_tty_sysfs(struct device *c) +{ + sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); +} diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c deleted file mode 100644 index fef8ce11e65d..000000000000 --- a/drivers/staging/dgap/dgap_sysfs.c +++ /dev/null @@ -1,792 +0,0 @@ -/* - * Copyright 2004 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - * - * - */ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dgap_driver.h" -#include "dgap_conf.h" -#include "dgap_parse.h" - - -static ssize_t dgap_driver_version_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART); -} -static DRIVER_ATTR(version, S_IRUSR, dgap_driver_version_show, NULL); - - -static ssize_t dgap_driver_boards_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%d\n", dgap_NumBoards); -} -static DRIVER_ATTR(boards, S_IRUSR, dgap_driver_boards_show, NULL); - - -static ssize_t dgap_driver_maxboards_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS); -} -static DRIVER_ATTR(maxboards, S_IRUSR, dgap_driver_maxboards_show, NULL); - - -static ssize_t dgap_driver_pollcounter_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%ld\n", dgap_poll_counter); -} -static DRIVER_ATTR(pollcounter, S_IRUSR, dgap_driver_pollcounter_show, NULL); - - -static ssize_t dgap_driver_state_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%s\n", dgap_driver_state_text[dgap_driver_state]); -} -static DRIVER_ATTR(state, S_IRUSR, dgap_driver_state_show, NULL); - - -static ssize_t dgap_driver_debug_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_debug); -} - -static ssize_t dgap_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count) -{ - sscanf(buf, "0x%x\n", &dgap_debug); - return count; -} -static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgap_driver_debug_show, dgap_driver_debug_store); - - -static ssize_t dgap_driver_rawreadok_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_rawreadok); -} - -static ssize_t dgap_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count) -{ - sscanf(buf, "0x%x\n", &dgap_rawreadok); - return count; -} -static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgap_driver_rawreadok_show, dgap_driver_rawreadok_store); - - -static ssize_t dgap_driver_pollrate_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%dms\n", dgap_poll_tick); -} - -static ssize_t dgap_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) -{ - sscanf(buf, "%d\n", &dgap_poll_tick); - return count; -} -static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, dgap_driver_pollrate_store); - - -void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) -{ - int rc = 0; - struct device_driver *driverfs = &dgap_driver->driver; - - rc |= driver_create_file(driverfs, &driver_attr_version); - rc |= driver_create_file(driverfs, &driver_attr_boards); - rc |= driver_create_file(driverfs, &driver_attr_maxboards); - rc |= driver_create_file(driverfs, &driver_attr_debug); - rc |= driver_create_file(driverfs, &driver_attr_rawreadok); - rc |= driver_create_file(driverfs, &driver_attr_pollrate); - rc |= driver_create_file(driverfs, &driver_attr_pollcounter); - rc |= driver_create_file(driverfs, &driver_attr_state); - if (rc) { - printk(KERN_ERR "DGAP: sysfs driver_create_file failed!\n"); - } -} - - -void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver) -{ - struct device_driver *driverfs = &dgap_driver->driver; - driver_remove_file(driverfs, &driver_attr_version); - driver_remove_file(driverfs, &driver_attr_boards); - driver_remove_file(driverfs, &driver_attr_maxboards); - driver_remove_file(driverfs, &driver_attr_debug); - driver_remove_file(driverfs, &driver_attr_rawreadok); - driver_remove_file(driverfs, &driver_attr_pollrate); - driver_remove_file(driverfs, &driver_attr_pollcounter); - driver_remove_file(driverfs, &driver_attr_state); -} - - -#define DGAP_VERIFY_BOARD(p, bd) \ - if (!p) \ - return (0); \ - \ - bd = dev_get_drvdata(p); \ - if (!bd || bd->magic != DGAP_BOARD_MAGIC) \ - return (0); \ - if (bd->state != BOARD_READY) \ - return (0); \ - - -static ssize_t dgap_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - for (i = 0; i < bd->nasync; i++) { - count += snprintf(buf + count, PAGE_SIZE - count, - "%d %s\n", bd->channels[i]->ch_portnum, - bd->channels[i]->ch_open_count ? "Open" : "Closed"); - } - return count; -} -static DEVICE_ATTR(ports_state, S_IRUSR, dgap_ports_state_show, NULL); - - -static ssize_t dgap_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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_baud_info); - } - return count; -} -static DEVICE_ATTR(ports_baud, S_IRUSR, dgap_ports_baud_show, NULL); - - -static ssize_t dgap_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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, - (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" : "", - (bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "", - (bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "", - (bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : ""); - } else { - count += snprintf(buf + count, PAGE_SIZE - count, - "%d\n", bd->channels[i]->ch_portnum); - } - } - return count; -} -static DEVICE_ATTR(ports_msignals, S_IRUSR, dgap_ports_msignals_show, NULL); - - -static ssize_t dgap_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_iflag, S_IRUSR, dgap_ports_iflag_show, NULL); - - -static ssize_t dgap_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_cflag, S_IRUSR, dgap_ports_cflag_show, NULL); - - -static ssize_t dgap_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_oflag, S_IRUSR, dgap_ports_oflag_show, NULL); - - -static ssize_t dgap_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_lflag, S_IRUSR, dgap_ports_lflag_show, NULL); - - -static ssize_t dgap_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgap_ports_digi_flag_show, NULL); - - -static ssize_t dgap_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgap_ports_rxcount_show, NULL); - - -static ssize_t dgap_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - int count = 0; - int i = 0; - - DGAP_VERIFY_BOARD(p, bd); - - 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); - } - return count; -} -static DEVICE_ATTR(ports_txcount, S_IRUSR, dgap_ports_txcount_show, NULL); - - -/* this function creates the sys files that will export each signal status - * to sysfs each value will be put in a separate filename - */ -void dgap_create_ports_sysfiles(struct board_t *bd) -{ - int rc = 0; - - dev_set_drvdata(&bd->pdev->dev, bd); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); - if (rc) { - printk(KERN_ERR "DGAP: sysfs device_create_file failed!\n"); - } -} - - -/* removes all the sys files created for that port */ -void dgap_remove_ports_sysfiles(struct board_t *bd) -{ - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount); -} - - -static ssize_t dgap_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); -} -static DEVICE_ATTR(state, S_IRUSR, dgap_tty_state_show, NULL); - - -static ssize_t dgap_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_baud_info); -} -static DEVICE_ATTR(baud, S_IRUSR, dgap_tty_baud_show, NULL); - - -static ssize_t dgap_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - if (ch->ch_open_count) { - return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n", - (ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "", - (ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "", - (ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "", - (ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "", - (ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "", - (ch->ch_mistat & UART_MSR_RI) ? "RI" : ""); - } - return 0; -} -static DEVICE_ATTR(msignals, S_IRUSR, dgap_tty_msignals_show, NULL); - - -static ssize_t dgap_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag); -} -static DEVICE_ATTR(iflag, S_IRUSR, dgap_tty_iflag_show, NULL); - - -static ssize_t dgap_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag); -} -static DEVICE_ATTR(cflag, S_IRUSR, dgap_tty_cflag_show, NULL); - - -static ssize_t dgap_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag); -} -static DEVICE_ATTR(oflag, S_IRUSR, dgap_tty_oflag_show, NULL); - - -static ssize_t dgap_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag); -} -static DEVICE_ATTR(lflag, S_IRUSR, dgap_tty_lflag_show, NULL); - - -static ssize_t dgap_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags); -} -static DEVICE_ATTR(digi_flag, S_IRUSR, dgap_tty_digi_flag_show, NULL); - - -static ssize_t dgap_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); -} -static DEVICE_ATTR(rxcount, S_IRUSR, dgap_tty_rxcount_show, NULL); - - -static ssize_t dgap_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); -} -static DEVICE_ATTR(txcount, S_IRUSR, dgap_tty_txcount_show, NULL); - - -static ssize_t dgap_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) -{ - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int cn; - int bn; - struct cnode *cptr = NULL; - int found = FALSE; - int ncount = 0; - int starto = 0; - int i = 0; - - if (!d) - return (0); - un = dev_get_drvdata(d); - if (!un || un->magic != DGAP_UNIT_MAGIC) - return (0); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return (0); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return (0); - if (bd->state != BOARD_READY) - return (0); - - bn = bd->boardnum; - cn = ch->ch_portnum; - - for (cptr = bd->bd_config; cptr; cptr = cptr->next) { - - if ((cptr->type == BNODE) && - ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || - (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || - (cptr->u.board.type == PAPORT8))) { - - found = TRUE; - if (cptr->u.board.v_start) - starto = cptr->u.board.start; - else - starto = 1; - } - - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } - else { - ptr1 = cptr->u.ttyname; - } - - for (i = 0; i < dgap_config_get_number_of_ports(bd); i++) { - if (cn == i) { - return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", - (un->un_type == DGAP_PRINT) ? "pr" : "tty", - ptr1, i + starto); - } - } - } - - if (cptr->type == CNODE) { - - for (i = 0; i < cptr->u.conc.nport; i++) { - if (cn == (i + ncount)) { - - return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", - (un->un_type == DGAP_PRINT) ? "pr" : "tty", - cptr->u.conc.id, - i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); - } - } - - ncount += cptr->u.conc.nport; - } - - if (cptr->type == MNODE) { - - for (i = 0; i < cptr->u.module.nport; i++) { - if (cn == (i + ncount)) { - return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", - (un->un_type == DGAP_PRINT) ? "pr" : "tty", - cptr->u.module.id, - i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); - } - } - - ncount += cptr->u.module.nport; - - } - } - - return snprintf(buf, PAGE_SIZE, "%s_dgap_%d_%d\n", - (un->un_type == DGAP_PRINT) ? "pr" : "tty", bn, cn); - -} -static DEVICE_ATTR(custom_name, S_IRUSR, dgap_tty_name_show, NULL); - - -static struct attribute *dgap_sysfs_tty_entries[] = { - &dev_attr_state.attr, - &dev_attr_baud.attr, - &dev_attr_msignals.attr, - &dev_attr_iflag.attr, - &dev_attr_cflag.attr, - &dev_attr_oflag.attr, - &dev_attr_lflag.attr, - &dev_attr_digi_flag.attr, - &dev_attr_rxcount.attr, - &dev_attr_txcount.attr, - &dev_attr_custom_name.attr, - NULL -}; - - -static struct attribute_group dgap_tty_attribute_group = { - .name = NULL, - .attrs = dgap_sysfs_tty_entries, -}; - - - - -void dgap_create_tty_sysfs(struct un_t *un, struct device *c) -{ - int ret; - - ret = sysfs_create_group(&c->kobj, &dgap_tty_attribute_group); - if (ret) { - printk(KERN_ERR "dgap: failed to create sysfs tty device attributes.\n"); - sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); - return; - } - - dev_set_drvdata(c, un); - -} - - -void dgap_remove_tty_sysfs(struct device *c) -{ - sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); -} From 69edaa21fcdf09f734b51f3efca3fd4ac9fe95f8 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:02 -0500 Subject: [PATCH 0438/1375] staging: dgap: Merge dgap_parses.c into dgap_driver.c There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 2 +- drivers/staging/dgap/dgap_driver.c | 1325 +++++++++++++++++++++++++++ drivers/staging/dgap/dgap_parse.c | 1373 ---------------------------- 3 files changed, 1326 insertions(+), 1374 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_parse.c diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index f5c9e357f500..13bf6fb37379 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -2,5 +2,5 @@ obj-$(CONFIG_DGAP) += dgap.o dgap-objs := dgap_driver.o \ - dgap_parse.o dgap_trace.o + dgap_trace.o diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 93b72d376ce8..cca35a0bf9e5 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -136,6 +136,16 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); static int dgap_event(struct board_t *bd); +/* + * Function prototypes from dgap_parse.c. + */ +static int dgap_gettok(char **in, struct cnode *p); +static char *dgap_getword(char **in); +static char *dgap_savestring(char *s); +static struct cnode *dgap_newnode(int t); +static int dgap_checknode(struct cnode *p); +static void dgap_err(char *s); + /* Driver load/unload functions */ int dgap_init_module(void); void dgap_cleanup_module(void); @@ -336,6 +346,68 @@ static const struct tty_operations dgap_tty_ops = { .send_xchar = dgap_tty_send_xchar }; +/* + * Our needed internal static variables from dgap_parse.c + */ +static struct cnode dgap_head; +#define MAXCWORD 200 +static char dgap_cword[MAXCWORD]; + +struct toklist { + int token; + char *string; +}; + +static struct toklist dgap_tlist[] = { + { BEGIN, "config_begin" }, + { END, "config_end" }, + { BOARD, "board" }, + { PCX, "Digi_AccelePort_C/X_PCI" }, /* C/X_PCI */ + { PEPC, "Digi_AccelePort_EPC/X_PCI" }, /* EPC/X_PCI */ + { PPCM, "Digi_AccelePort_Xem_PCI" }, /* PCI/Xem */ + { APORT2_920P, "Digi_AccelePort_2r_920_PCI" }, + { APORT4_920P, "Digi_AccelePort_4r_920_PCI" }, + { APORT8_920P, "Digi_AccelePort_8r_920_PCI" }, + { PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" }, + { PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" }, + { IO, "io" }, + { PCIINFO, "pciinfo" }, + { LINE, "line" }, + { CONC, "conc" }, + { CONC, "concentrator" }, + { CX, "cx" }, + { CX, "ccon" }, + { EPC, "epccon" }, + { EPC, "epc" }, + { MOD, "module" }, + { ID, "id" }, + { STARTO, "start" }, + { SPEED, "speed" }, + { CABLE, "cable" }, + { CONNECT, "connect" }, + { METHOD, "method" }, + { STATUS, "status" }, + { CUSTOM, "Custom" }, + { BASIC, "Basic" }, + { MEM, "mem" }, + { MEM, "memory" }, + { PORTS, "ports" }, + { MODEM, "modem" }, + { NPORTS, "nports" }, + { TTYN, "ttyname" }, + { CU, "cuname" }, + { PRINT, "prname" }, + { CMAJOR, "major" }, + { ALTPIN, "altpin" }, + { USEINTR, "useintr" }, + { TTSIZ, "ttysize" }, + { CHSIZ, "chsize" }, + { BSSIZ, "boardsize" }, + { UNTSIZ, "schedsize" }, + { F2SIZ, "f2200size" }, + { VPSIZ, "vpixsize" }, + { 0, NULL } +}; /************************************************************************ * @@ -7128,3 +7200,1256 @@ void dgap_remove_tty_sysfs(struct device *c) { sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); } + +/* + * Parse a configuration file read into memory as a string. + */ +int dgap_parsefile(char **in, int Remove) +{ + struct cnode *p, *brd, *line, *conc; + int rc; + char *s = NULL, *s2 = NULL; + int linecnt = 0; + + p = &dgap_head; + brd = line = conc = NULL; + + /* perhaps we are adding to an existing list? */ + while (p->next != NULL) { + p = p->next; + } + + /* file must start with a BEGIN */ + while ( (rc = dgap_gettok(in,p)) != BEGIN ) { + if (rc == 0) { + dgap_err("unexpected EOF"); + return(-1); + } + } + + for (; ; ) { + rc = dgap_gettok(in,p); + if (rc == 0) { + dgap_err("unexpected EOF"); + return(-1); + } + + switch (rc) { + case 0: + dgap_err("unexpected end of file"); + return(-1); + + case BEGIN: /* should only be 1 begin */ + dgap_err("unexpected config_begin\n"); + return(-1); + + case END: + return(0); + + case BOARD: /* board info */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(BNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + + p->u.board.status = dgap_savestring("No"); + line = conc = NULL; + brd = p; + linecnt = -1; + break; + + case APORT2_920P: /* AccelePort_4 */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_2r_920 string"); + return(-1); + } + p->u.board.type = APORT2_920P; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_2r_920 PCI to config...\n")); + break; + + case APORT4_920P: /* AccelePort_4 */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_4r_920 string"); + return(-1); + } + p->u.board.type = APORT4_920P; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_4r_920 PCI to config...\n")); + break; + + case APORT8_920P: /* AccelePort_8 */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_8r_920 string"); + return(-1); + } + p->u.board.type = APORT8_920P; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_8r_920 PCI to config...\n")); + break; + + case PAPORT4: /* AccelePort_4 PCI */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_4r(PCI) string"); + return(-1); + } + p->u.board.type = PAPORT4; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_4r PCI to config...\n")); + break; + + case PAPORT8: /* AccelePort_8 PCI */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_8r string"); + return(-1); + } + p->u.board.type = PAPORT8; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_8r PCI to config...\n")); + break; + + case PCX: /* PCI C/X */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_C/X_(PCI) string"); + return(-1); + } + p->u.board.type = PCX; + p->u.board.v_type = 1; + p->u.board.conc1 = 0; + p->u.board.conc2 = 0; + p->u.board.module1 = 0; + p->u.board.module2 = 0; + DPR_INIT(("Adding PCI C/X to config...\n")); + break; + + case PEPC: /* PCI EPC/X */ + if (p->type != BNODE) { + dgap_err("unexpected \"Digi_EPC/X_(PCI)\" string"); + return(-1); + } + p->u.board.type = PEPC; + p->u.board.v_type = 1; + p->u.board.conc1 = 0; + p->u.board.conc2 = 0; + p->u.board.module1 = 0; + p->u.board.module2 = 0; + DPR_INIT(("Adding PCI EPC/X to config...\n")); + break; + + case PPCM: /* PCI/Xem */ + if (p->type != BNODE) { + dgap_err("unexpected PCI/Xem string"); + return(-1); + } + p->u.board.type = PPCM; + p->u.board.v_type = 1; + p->u.board.conc1 = 0; + p->u.board.conc2 = 0; + DPR_INIT(("Adding PCI XEM to config...\n")); + break; + + case IO: /* i/o port */ + if (p->type != BNODE) { + dgap_err("IO port only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.portstr = dgap_savestring(s); + p->u.board.port = (short)simple_strtol(s, &s2, 0); + if ((short)strlen(s) > (short)(s2 - s)) { + dgap_err("bad number for IO port"); + return(-1); + } + p->u.board.v_port = 1; + DPR_INIT(("Adding IO (%s) to config...\n", s)); + break; + + case MEM: /* memory address */ + if (p->type != BNODE) { + dgap_err("memory address only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.addrstr = dgap_savestring(s); + p->u.board.addr = simple_strtoul(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for memory address"); + return(-1); + } + p->u.board.v_addr = 1; + DPR_INIT(("Adding MEM (%s) to config...\n", s)); + break; + + case PCIINFO: /* pci information */ + if (p->type != BNODE) { + dgap_err("memory address only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.pcibusstr = dgap_savestring(s); + p->u.board.pcibus = simple_strtoul(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for pci bus"); + return(-1); + } + p->u.board.v_pcibus = 1; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.pcislotstr = dgap_savestring(s); + p->u.board.pcislot = simple_strtoul(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for pci slot"); + return(-1); + } + p->u.board.v_pcislot = 1; + + DPR_INIT(("Adding PCIINFO (%s %s) to config...\n", p->u.board.pcibusstr, + p->u.board.pcislotstr)); + break; + + case METHOD: + if (p->type != BNODE) { + dgap_err("install method only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.method = dgap_savestring(s); + p->u.board.v_method = 1; + DPR_INIT(("Adding METHOD (%s) to config...\n", s)); + break; + + case STATUS: + if (p->type != BNODE) { + dgap_err("config status only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.status = dgap_savestring(s); + DPR_INIT(("Adding STATUS (%s) to config...\n", s)); + break; + + case NPORTS: /* number of ports */ + if (p->type == BNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.nport = (char)simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for number of ports"); + return(-1); + } + p->u.board.v_nport = 1; + } else if (p->type == CNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.nport = (char)simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for number of ports"); + return(-1); + } + p->u.conc.v_nport = 1; + } else if (p->type == MNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.module.nport = (char)simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for number of ports"); + return(-1); + } + p->u.module.v_nport = 1; + } else { + dgap_err("nports only valid for concentrators or modules"); + return(-1); + } + DPR_INIT(("Adding NPORTS (%s) to config...\n", s)); + break; + + case ID: /* letter ID used in tty name */ + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + + p->u.board.status = dgap_savestring(s); + + if (p->type == CNODE) { + p->u.conc.id = dgap_savestring(s); + p->u.conc.v_id = 1; + } else if (p->type == MNODE) { + p->u.module.id = dgap_savestring(s); + p->u.module.v_id = 1; + } else { + dgap_err("id only valid for concentrators or modules"); + return(-1); + } + DPR_INIT(("Adding ID (%s) to config...\n", s)); + break; + + case STARTO: /* start offset of ID */ + if (p->type == BNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.start = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for start of tty count"); + return(-1); + } + p->u.board.v_start = 1; + } else if (p->type == CNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.start = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for start of tty count"); + return(-1); + } + p->u.conc.v_start = 1; + } else if (p->type == MNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.module.start = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for start of tty count"); + return(-1); + } + p->u.module.v_start = 1; + } else { + dgap_err("start only valid for concentrators or modules"); + return(-1); + } + DPR_INIT(("Adding START (%s) to config...\n", s)); + break; + + case TTYN: /* tty name prefix */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(TNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if ( (s = dgap_getword(in)) == NULL ) { + dgap_err("unexpeced end of file"); + return(-1); + } + if ( (p->u.ttyname = dgap_savestring(s)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + DPR_INIT(("Adding TTY (%s) to config...\n", s)); + break; + + case CU: /* cu name prefix */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(CUNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if ( (s = dgap_getword(in)) == NULL ) { + dgap_err("unexpeced end of file"); + return(-1); + } + if ( (p->u.cuname = dgap_savestring(s)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + DPR_INIT(("Adding CU (%s) to config...\n", s)); + break; + + case LINE: /* line information */ + if (dgap_checknode(p)) + return(-1); + if (brd == NULL) { + dgap_err("must specify board before line info"); + return(-1); + } + switch (brd->u.board.type) { + case PPCM: + dgap_err("line not vaild for PC/em"); + return(-1); + } + if ( (p->next = dgap_newnode(LNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + conc = NULL; + line = p; + linecnt++; + DPR_INIT(("Adding LINE to config...\n")); + break; + + case CONC: /* concentrator information */ + if (dgap_checknode(p)) + return(-1); + if (line == NULL) { + dgap_err("must specify line info before concentrator"); + return(-1); + } + if ( (p->next = dgap_newnode(CNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + conc = p; + if (linecnt) + brd->u.board.conc2++; + else + brd->u.board.conc1++; + + DPR_INIT(("Adding CONC to config...\n")); + break; + + case CX: /* c/x type concentrator */ + if (p->type != CNODE) { + dgap_err("cx only valid for concentrators"); + return(-1); + } + p->u.conc.type = CX; + p->u.conc.v_type = 1; + DPR_INIT(("Adding CX to config...\n")); + break; + + case EPC: /* epc type concentrator */ + if (p->type != CNODE) { + dgap_err("cx only valid for concentrators"); + return(-1); + } + p->u.conc.type = EPC; + p->u.conc.v_type = 1; + DPR_INIT(("Adding EPC to config...\n")); + break; + + case MOD: /* EBI module */ + if (dgap_checknode(p)) + return(-1); + if (brd == NULL) { + dgap_err("must specify board info before EBI modules"); + return(-1); + } + switch (brd->u.board.type) { + case PPCM: + linecnt = 0; + break; + default: + if (conc == NULL) { + dgap_err("must specify concentrator info before EBI module"); + return(-1); + } + } + if ( (p->next = dgap_newnode(MNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if (linecnt) + brd->u.board.module2++; + else + brd->u.board.module1++; + + DPR_INIT(("Adding MOD to config...\n")); + break; + + case PORTS: /* ports type EBI module */ + if (p->type != MNODE) { + dgap_err("ports only valid for EBI modules"); + return(-1); + } + p->u.module.type = PORTS; + p->u.module.v_type = 1; + DPR_INIT(("Adding PORTS to config...\n")); + break; + + case MODEM: /* ports type EBI module */ + if (p->type != MNODE) { + dgap_err("modem only valid for modem modules"); + return(-1); + } + p->u.module.type = MODEM; + p->u.module.v_type = 1; + DPR_INIT(("Adding MODEM to config...\n")); + break; + + case CABLE: + if (p->type == LNODE) { + if ((s = dgap_getword(in)) == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.line.cable = dgap_savestring(s); + p->u.line.v_cable = 1; + } + DPR_INIT(("Adding CABLE (%s) to config...\n", s)); + break; + + case SPEED: /* sync line speed indication */ + if (p->type == LNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.line.speed = (char)simple_strtol(s, &s2, 0); + if ((short)strlen(s) > (short)(s2 - s)) { + dgap_err("bad number for line speed"); + return(-1); + } + p->u.line.v_speed = 1; + } else if (p->type == CNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.speed = (char)simple_strtol(s, &s2, 0); + if ((short)strlen(s) > (short)(s2 - s)) { + dgap_err("bad number for line speed"); + return(-1); + } + p->u.conc.v_speed = 1; + } else { + dgap_err("speed valid only for lines or concentrators."); + return(-1); + } + DPR_INIT(("Adding SPEED (%s) to config...\n", s)); + break; + + case CONNECT: + if (p->type == CNODE) { + if ((s = dgap_getword(in)) == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.connect = dgap_savestring(s); + p->u.conc.v_connect = 1; + } + DPR_INIT(("Adding CONNECT (%s) to config...\n", s)); + break; + case PRINT: /* transparent print name prefix */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(PNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if ( (s = dgap_getword(in)) == NULL ) { + dgap_err("unexpeced end of file"); + return(-1); + } + if ( (p->u.printname = dgap_savestring(s)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + DPR_INIT(("Adding PRINT (%s) to config...\n", s)); + break; + + case CMAJOR: /* major number */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(JNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.majornumber = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for major number"); + return(-1); + } + DPR_INIT(("Adding CMAJOR (%s) to config...\n", s)); + break; + + case ALTPIN: /* altpin setting */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(ANODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.altpin = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for altpin"); + return(-1); + } + DPR_INIT(("Adding ALTPIN (%s) to config...\n", s)); + break; + + case USEINTR: /* enable interrupt setting */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(INTRNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.useintr = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for useintr"); + return(-1); + } + DPR_INIT(("Adding USEINTR (%s) to config...\n", s)); + break; + + case TTSIZ: /* size of tty structure */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(TSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.ttysize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for ttysize"); + return(-1); + } + DPR_INIT(("Adding TTSIZ (%s) to config...\n", s)); + break; + + case CHSIZ: /* channel structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(CSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.chsize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for chsize"); + return(-1); + } + DPR_INIT(("Adding CHSIZE (%s) to config...\n", s)); + break; + + case BSSIZ: /* board structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(BSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.bssize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for bssize"); + return(-1); + } + DPR_INIT(("Adding BSSIZ (%s) to config...\n", s)); + break; + + case UNTSIZ: /* sched structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(USNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.unsize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for schedsize"); + return(-1); + } + DPR_INIT(("Adding UNTSIZ (%s) to config...\n", s)); + break; + + case F2SIZ: /* f2200 structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(FSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.f2size = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for f2200size"); + return(-1); + } + DPR_INIT(("Adding F2SIZ (%s) to config...\n", s)); + break; + + case VPSIZ: /* vpix structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(VSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.vpixsize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for vpixsize"); + return(-1); + } + DPR_INIT(("Adding VPSIZ (%s) to config...\n", s)); + break; + } + } +} + + +/* + * 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. + */ +static char *dgap_sindex (char *string, char *group) +{ + char *ptr; + + if (!string || !group) + return (char *) NULL; + + if (*group == '^') { + group++; + for (; *string; string++) { + for (ptr = group; *ptr; ptr++) { + if (*ptr == *string) + break; + } + if (*ptr == '\0') + return string; + } + } + else { + for (; *string; string++) { + for (ptr = group; *ptr; ptr++) { + if (*ptr == *string) + return string; + } + } + } + + return (char *) NULL; +} + + +/* + * Get a token from the input file; return 0 if end of file is reached + */ +static int dgap_gettok(char **in, struct cnode *p) +{ + char *w; + struct toklist *t; + + if (strstr(dgap_cword, "boar")) { + w = dgap_getword(in); + snprintf(dgap_cword, MAXCWORD, "%s", w); + for (t = dgap_tlist; t->token != 0; t++) { + if ( !strcmp(w, t->string)) { + return(t->token); + } + } + dgap_err("board !!type not specified"); + return(1); + } + else { + while ( (w = dgap_getword(in)) != NULL ) { + snprintf(dgap_cword, MAXCWORD, "%s", w); + for (t = dgap_tlist; t->token != 0; t++) { + if ( !strcmp(w, t->string) ) + return(t->token); + } + } + return(0); + } +} + + +/* + * get a word from the input stream, also keep track of current line number. + * words are separated by whitespace. + */ +static char *dgap_getword(char **in) +{ + char *ret_ptr = *in; + + char *ptr = dgap_sindex(*in, " \t\n"); + + /* If no word found, return null */ + if (!ptr) + return NULL; + + /* Mark new location for our buffer */ + *ptr = '\0'; + *in = ptr + 1; + + /* Eat any extra spaces/tabs/newlines that might be present */ + while (*in && **in && ((**in == ' ') || (**in == '\t') || (**in == '\n'))) { + **in = '\0'; + *in = *in + 1; + } + + return ret_ptr; +} + + +/* + * print an error message, giving the line number in the file where + * the error occurred. + */ +static void dgap_err(char *s) +{ + printk("DGAP: parse: %s\n", s); +} + + +/* + * allocate a new configuration node of type t + */ +static struct cnode *dgap_newnode(int t) +{ + struct cnode *n; + + n = kmalloc(sizeof(struct cnode), GFP_ATOMIC); + if (n != NULL) { + memset((char *)n, 0, sizeof(struct cnode)); + n->type = t; + } + return(n); +} + + +/* + * dgap_checknode: see if all the necessary info has been supplied for a node + * before creating the next node. + */ +static int dgap_checknode(struct cnode *p) +{ + switch (p->type) { + case BNODE: + if (p->u.board.v_type == 0) { + dgap_err("board type !not specified"); + return(1); + } + + return(0); + + case LNODE: + if (p->u.line.v_speed == 0) { + dgap_err("line speed not specified"); + return(1); + } + return(0); + + case CNODE: + if (p->u.conc.v_type == 0) { + dgap_err("concentrator type not specified"); + return(1); + } + if (p->u.conc.v_speed == 0) { + dgap_err("concentrator line speed not specified"); + return(1); + } + if (p->u.conc.v_nport == 0) { + dgap_err("number of ports on concentrator not specified"); + return(1); + } + if (p->u.conc.v_id == 0) { + dgap_err("concentrator id letter not specified"); + return(1); + } + return(0); + + case MNODE: + if (p->u.module.v_type == 0) { + dgap_err("EBI module type not specified"); + return(1); + } + if (p->u.module.v_nport == 0) { + dgap_err("number of ports on EBI module not specified"); + return(1); + } + if (p->u.module.v_id == 0) { + dgap_err("EBI module id letter not specified"); + return(1); + } + return(0); + } + return(0); +} + +/* + * save a string somewhere + */ +static char *dgap_savestring(char *s) +{ + char *p; + if ( (p = kmalloc(strlen(s) + 1, GFP_ATOMIC) ) != NULL) { + strcpy(p, s); + } + return(p); +} + + +/* + * Given a board pointer, returns whether we should use interrupts or not. + */ +uint dgap_config_get_useintr(struct board_t *bd) +{ + struct cnode *p = NULL; + + if (!bd) + return(0); + + for (p = bd->bd_config; p; p = p->next) { + switch (p->type) { + case INTRNODE: + /* + * check for pcxr types. + */ + return p->u.useintr; + default: + break; + } + } + + /* If not found, then don't turn on interrupts. */ + return 0; +} + + +/* + * Given a board pointer, returns whether we turn on altpin or not. + */ +uint dgap_config_get_altpin(struct board_t *bd) +{ + struct cnode *p = NULL; + + if (!bd) + return(0); + + for (p = bd->bd_config; p; p = p->next) { + switch (p->type) { + case ANODE: + /* + * check for pcxr types. + */ + return p->u.altpin; + default: + break; + } + } + + /* If not found, then don't turn on interrupts. */ + return 0; +} + + + +/* + * Given a specific type of board, if found, detached link and + * returns the first occurrence in the list. + */ +struct cnode *dgap_find_config(int type, int bus, int slot) +{ + struct cnode *p, *prev = NULL, *prev2 = NULL, *found = NULL; + + p = &dgap_head; + + while (p->next != NULL) { + prev = p; + p = p->next; + + if (p->type == BNODE) { + + if (p->u.board.type == type) { + + if (p->u.board.v_pcibus && p->u.board.pcibus != bus) { + DPR(("Found matching board, but wrong bus position. System says bus %d, we want bus %ld\n", + bus, p->u.board.pcibus)); + continue; + } + if (p->u.board.v_pcislot && p->u.board.pcislot != slot) { + DPR_INIT(("Found matching board, but wrong slot position. System says slot %d, we want slot %ld\n", + slot, p->u.board.pcislot)); + continue; + } + + DPR_INIT(("Matched type in config file\n")); + + found = p; + /* + * Keep walking thru the list till we find the next board. + */ + while (p->next != NULL) { + prev2 = p; + p = p->next; + if (p->type == BNODE) { + + /* + * Mark the end of our 1 board chain of configs. + */ + prev2->next = NULL; + + /* + * Link the "next" board to the previous board, + * effectively "unlinking" our board from the main config. + */ + prev->next = p; + + return found; + } + } + /* + * It must be the last board in the list. + */ + prev->next = NULL; + return found; + } + } + } + return NULL; +} + +/* + * Given a board pointer, walks the config link, counting up + * all ports user specified should be on the board. + * (This does NOT mean they are all actually present right now tho) + */ +uint dgap_config_get_number_of_ports(struct board_t *bd) +{ + int count = 0; + struct cnode *p = NULL; + + if (!bd) + return(0); + + for (p = bd->bd_config; p; p = p->next) { + + switch (p->type) { + case BNODE: + /* + * check for pcxr types. + */ + if (p->u.board.type > EPCFE) + count += p->u.board.nport; + break; + case CNODE: + count += p->u.conc.nport; + break; + case MNODE: + count += p->u.module.nport; + break; + } + } + return (count); +} + +char *dgap_create_config_string(struct board_t *bd, char *string) +{ + char *ptr = string; + struct cnode *p = NULL; + struct cnode *q = NULL; + int speed; + + if (!bd) { + *ptr = 0xff; + return string; + } + + for (p = bd->bd_config; p; p = p->next) { + + switch (p->type) { + case LNODE: + *ptr = '\0'; + ptr++; + *ptr = p->u.line.speed; + ptr++; + break; + case CNODE: + /* + * Because the EPC/con concentrators can have EM modules + * hanging off of them, we have to walk ahead in the list + * and keep adding the number of ports on each EM to the config. + * UGH! + */ + speed = p->u.conc.speed; + q = p->next; + if ((q != NULL) && (q->type == MNODE) ) { + *ptr = (p->u.conc.nport + 0x80); + ptr++; + p = q; + while ((q->next != NULL) && (q->next->type) == MNODE) { + *ptr = (q->u.module.nport + 0x80); + ptr++; + p = q; + q = q->next; + } + *ptr = q->u.module.nport; + ptr++; + } else { + *ptr = p->u.conc.nport; + ptr++; + } + + *ptr = speed; + ptr++; + break; + } + } + + *ptr = 0xff; + return string; +} + + + +char *dgap_get_config_letters(struct board_t *bd, char *string) +{ + int found = FALSE; + char *ptr = string; + struct cnode *cptr = NULL; + int len = 0; + int left = MAXTTYNAMELEN; + + if (!bd) { + return ""; + } + + for (cptr = bd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + if (ptr1) { + len = snprintf(ptr, left, "%s", ptr1); + left -= len; + ptr += len; + if (left <= 0) + break; + } + } + + if (cptr->type == CNODE) { + if (cptr->u.conc.id) { + len = snprintf(ptr, left, "%s", cptr->u.conc.id); + left -= len; + ptr += len; + if (left <= 0) + break; + } + } + + if (cptr->type == MNODE) { + if (cptr->u.module.id) { + len = snprintf(ptr, left, "%s", cptr->u.module.id); + left -= len; + ptr += len; + if (left <= 0) + break; + } + } + } + + return string; +} diff --git a/drivers/staging/dgap/dgap_parse.c b/drivers/staging/dgap/dgap_parse.c deleted file mode 100644 index 65cd6127951b..000000000000 --- a/drivers/staging/dgap/dgap_parse.c +++ /dev/null @@ -1,1373 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - * - ***************************************************************************** - * - * dgap_parse.c - Parses the configuration information from the input file. - * - * - */ -#include -#include -#include - -#include "dgap_types.h" -#include "dgap_fep5.h" -#include "dgap_driver.h" -#include "dgap_parse.h" -#include "dgap_conf.h" - - -/* - * Function prototypes. - */ -static int dgap_gettok(char **in, struct cnode *p); -static char *dgap_getword(char **in); -static char *dgap_savestring(char *s); -static struct cnode *dgap_newnode(int t); -static int dgap_checknode(struct cnode *p); -static void dgap_err(char *s); - -/* - * Our needed internal static variables... - */ -static struct cnode dgap_head; -#define MAXCWORD 200 -static char dgap_cword[MAXCWORD]; - -struct toklist { - int token; - char *string; -}; - -static struct toklist dgap_tlist[] = { - { BEGIN, "config_begin" }, - { END, "config_end" }, - { BOARD, "board" }, - { PCX, "Digi_AccelePort_C/X_PCI" }, /* C/X_PCI */ - { PEPC, "Digi_AccelePort_EPC/X_PCI" }, /* EPC/X_PCI */ - { PPCM, "Digi_AccelePort_Xem_PCI" }, /* PCI/Xem */ - { APORT2_920P, "Digi_AccelePort_2r_920_PCI" }, - { APORT4_920P, "Digi_AccelePort_4r_920_PCI" }, - { APORT8_920P, "Digi_AccelePort_8r_920_PCI" }, - { PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" }, - { PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" }, - { IO, "io" }, - { PCIINFO, "pciinfo" }, - { LINE, "line" }, - { CONC, "conc" }, - { CONC, "concentrator" }, - { CX, "cx" }, - { CX, "ccon" }, - { EPC, "epccon" }, - { EPC, "epc" }, - { MOD, "module" }, - { ID, "id" }, - { STARTO, "start" }, - { SPEED, "speed" }, - { CABLE, "cable" }, - { CONNECT, "connect" }, - { METHOD, "method" }, - { STATUS, "status" }, - { CUSTOM, "Custom" }, - { BASIC, "Basic" }, - { MEM, "mem" }, - { MEM, "memory" }, - { PORTS, "ports" }, - { MODEM, "modem" }, - { NPORTS, "nports" }, - { TTYN, "ttyname" }, - { CU, "cuname" }, - { PRINT, "prname" }, - { CMAJOR, "major" }, - { ALTPIN, "altpin" }, - { USEINTR, "useintr" }, - { TTSIZ, "ttysize" }, - { CHSIZ, "chsize" }, - { BSSIZ, "boardsize" }, - { UNTSIZ, "schedsize" }, - { F2SIZ, "f2200size" }, - { VPSIZ, "vpixsize" }, - { 0, NULL } -}; - - -/* - * Parse a configuration file read into memory as a string. - */ -int dgap_parsefile(char **in, int Remove) -{ - struct cnode *p, *brd, *line, *conc; - int rc; - char *s = NULL, *s2 = NULL; - int linecnt = 0; - - p = &dgap_head; - brd = line = conc = NULL; - - /* perhaps we are adding to an existing list? */ - while (p->next != NULL) { - p = p->next; - } - - /* file must start with a BEGIN */ - while ( (rc = dgap_gettok(in,p)) != BEGIN ) { - if (rc == 0) { - dgap_err("unexpected EOF"); - return(-1); - } - } - - for (; ; ) { - rc = dgap_gettok(in,p); - if (rc == 0) { - dgap_err("unexpected EOF"); - return(-1); - } - - switch (rc) { - case 0: - dgap_err("unexpected end of file"); - return(-1); - - case BEGIN: /* should only be 1 begin */ - dgap_err("unexpected config_begin\n"); - return(-1); - - case END: - return(0); - - case BOARD: /* board info */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(BNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - - p->u.board.status = dgap_savestring("No"); - line = conc = NULL; - brd = p; - linecnt = -1; - break; - - case APORT2_920P: /* AccelePort_4 */ - if (p->type != BNODE) { - dgap_err("unexpected Digi_2r_920 string"); - return(-1); - } - p->u.board.type = APORT2_920P; - p->u.board.v_type = 1; - DPR_INIT(("Adding Digi_2r_920 PCI to config...\n")); - break; - - case APORT4_920P: /* AccelePort_4 */ - if (p->type != BNODE) { - dgap_err("unexpected Digi_4r_920 string"); - return(-1); - } - p->u.board.type = APORT4_920P; - p->u.board.v_type = 1; - DPR_INIT(("Adding Digi_4r_920 PCI to config...\n")); - break; - - case APORT8_920P: /* AccelePort_8 */ - if (p->type != BNODE) { - dgap_err("unexpected Digi_8r_920 string"); - return(-1); - } - p->u.board.type = APORT8_920P; - p->u.board.v_type = 1; - DPR_INIT(("Adding Digi_8r_920 PCI to config...\n")); - break; - - case PAPORT4: /* AccelePort_4 PCI */ - if (p->type != BNODE) { - dgap_err("unexpected Digi_4r(PCI) string"); - return(-1); - } - p->u.board.type = PAPORT4; - p->u.board.v_type = 1; - DPR_INIT(("Adding Digi_4r PCI to config...\n")); - break; - - case PAPORT8: /* AccelePort_8 PCI */ - if (p->type != BNODE) { - dgap_err("unexpected Digi_8r string"); - return(-1); - } - p->u.board.type = PAPORT8; - p->u.board.v_type = 1; - DPR_INIT(("Adding Digi_8r PCI to config...\n")); - break; - - case PCX: /* PCI C/X */ - if (p->type != BNODE) { - dgap_err("unexpected Digi_C/X_(PCI) string"); - return(-1); - } - p->u.board.type = PCX; - p->u.board.v_type = 1; - p->u.board.conc1 = 0; - p->u.board.conc2 = 0; - p->u.board.module1 = 0; - p->u.board.module2 = 0; - DPR_INIT(("Adding PCI C/X to config...\n")); - break; - - case PEPC: /* PCI EPC/X */ - if (p->type != BNODE) { - dgap_err("unexpected \"Digi_EPC/X_(PCI)\" string"); - return(-1); - } - p->u.board.type = PEPC; - p->u.board.v_type = 1; - p->u.board.conc1 = 0; - p->u.board.conc2 = 0; - p->u.board.module1 = 0; - p->u.board.module2 = 0; - DPR_INIT(("Adding PCI EPC/X to config...\n")); - break; - - case PPCM: /* PCI/Xem */ - if (p->type != BNODE) { - dgap_err("unexpected PCI/Xem string"); - return(-1); - } - p->u.board.type = PPCM; - p->u.board.v_type = 1; - p->u.board.conc1 = 0; - p->u.board.conc2 = 0; - DPR_INIT(("Adding PCI XEM to config...\n")); - break; - - case IO: /* i/o port */ - if (p->type != BNODE) { - dgap_err("IO port only vaild for boards"); - return(-1); - } - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.portstr = dgap_savestring(s); - p->u.board.port = (short)simple_strtol(s, &s2, 0); - if ((short)strlen(s) > (short)(s2 - s)) { - dgap_err("bad number for IO port"); - return(-1); - } - p->u.board.v_port = 1; - DPR_INIT(("Adding IO (%s) to config...\n", s)); - break; - - case MEM: /* memory address */ - if (p->type != BNODE) { - dgap_err("memory address only vaild for boards"); - return(-1); - } - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.addrstr = dgap_savestring(s); - p->u.board.addr = simple_strtoul(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for memory address"); - return(-1); - } - p->u.board.v_addr = 1; - DPR_INIT(("Adding MEM (%s) to config...\n", s)); - break; - - case PCIINFO: /* pci information */ - if (p->type != BNODE) { - dgap_err("memory address only vaild for boards"); - return(-1); - } - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.pcibusstr = dgap_savestring(s); - p->u.board.pcibus = simple_strtoul(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for pci bus"); - return(-1); - } - p->u.board.v_pcibus = 1; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.pcislotstr = dgap_savestring(s); - p->u.board.pcislot = simple_strtoul(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for pci slot"); - return(-1); - } - p->u.board.v_pcislot = 1; - - DPR_INIT(("Adding PCIINFO (%s %s) to config...\n", p->u.board.pcibusstr, - p->u.board.pcislotstr)); - break; - - case METHOD: - if (p->type != BNODE) { - dgap_err("install method only vaild for boards"); - return(-1); - } - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.method = dgap_savestring(s); - p->u.board.v_method = 1; - DPR_INIT(("Adding METHOD (%s) to config...\n", s)); - break; - - case STATUS: - if (p->type != BNODE) { - dgap_err("config status only vaild for boards"); - return(-1); - } - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.status = dgap_savestring(s); - DPR_INIT(("Adding STATUS (%s) to config...\n", s)); - break; - - case NPORTS: /* number of ports */ - if (p->type == BNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.nport = (char)simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for number of ports"); - return(-1); - } - p->u.board.v_nport = 1; - } else if (p->type == CNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.conc.nport = (char)simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for number of ports"); - return(-1); - } - p->u.conc.v_nport = 1; - } else if (p->type == MNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.module.nport = (char)simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for number of ports"); - return(-1); - } - p->u.module.v_nport = 1; - } else { - dgap_err("nports only valid for concentrators or modules"); - return(-1); - } - DPR_INIT(("Adding NPORTS (%s) to config...\n", s)); - break; - - case ID: /* letter ID used in tty name */ - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - - p->u.board.status = dgap_savestring(s); - - if (p->type == CNODE) { - p->u.conc.id = dgap_savestring(s); - p->u.conc.v_id = 1; - } else if (p->type == MNODE) { - p->u.module.id = dgap_savestring(s); - p->u.module.v_id = 1; - } else { - dgap_err("id only valid for concentrators or modules"); - return(-1); - } - DPR_INIT(("Adding ID (%s) to config...\n", s)); - break; - - case STARTO: /* start offset of ID */ - if (p->type == BNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.board.start = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for start of tty count"); - return(-1); - } - p->u.board.v_start = 1; - } else if (p->type == CNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.conc.start = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for start of tty count"); - return(-1); - } - p->u.conc.v_start = 1; - } else if (p->type == MNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.module.start = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for start of tty count"); - return(-1); - } - p->u.module.v_start = 1; - } else { - dgap_err("start only valid for concentrators or modules"); - return(-1); - } - DPR_INIT(("Adding START (%s) to config...\n", s)); - break; - - case TTYN: /* tty name prefix */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(TNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - if ( (s = dgap_getword(in)) == NULL ) { - dgap_err("unexpeced end of file"); - return(-1); - } - if ( (p->u.ttyname = dgap_savestring(s)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - DPR_INIT(("Adding TTY (%s) to config...\n", s)); - break; - - case CU: /* cu name prefix */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(CUNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - if ( (s = dgap_getword(in)) == NULL ) { - dgap_err("unexpeced end of file"); - return(-1); - } - if ( (p->u.cuname = dgap_savestring(s)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - DPR_INIT(("Adding CU (%s) to config...\n", s)); - break; - - case LINE: /* line information */ - if (dgap_checknode(p)) - return(-1); - if (brd == NULL) { - dgap_err("must specify board before line info"); - return(-1); - } - switch (brd->u.board.type) { - case PPCM: - dgap_err("line not vaild for PC/em"); - return(-1); - } - if ( (p->next = dgap_newnode(LNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - conc = NULL; - line = p; - linecnt++; - DPR_INIT(("Adding LINE to config...\n")); - break; - - case CONC: /* concentrator information */ - if (dgap_checknode(p)) - return(-1); - if (line == NULL) { - dgap_err("must specify line info before concentrator"); - return(-1); - } - if ( (p->next = dgap_newnode(CNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - conc = p; - if (linecnt) - brd->u.board.conc2++; - else - brd->u.board.conc1++; - - DPR_INIT(("Adding CONC to config...\n")); - break; - - case CX: /* c/x type concentrator */ - if (p->type != CNODE) { - dgap_err("cx only valid for concentrators"); - return(-1); - } - p->u.conc.type = CX; - p->u.conc.v_type = 1; - DPR_INIT(("Adding CX to config...\n")); - break; - - case EPC: /* epc type concentrator */ - if (p->type != CNODE) { - dgap_err("cx only valid for concentrators"); - return(-1); - } - p->u.conc.type = EPC; - p->u.conc.v_type = 1; - DPR_INIT(("Adding EPC to config...\n")); - break; - - case MOD: /* EBI module */ - if (dgap_checknode(p)) - return(-1); - if (brd == NULL) { - dgap_err("must specify board info before EBI modules"); - return(-1); - } - switch (brd->u.board.type) { - case PPCM: - linecnt = 0; - break; - default: - if (conc == NULL) { - dgap_err("must specify concentrator info before EBI module"); - return(-1); - } - } - if ( (p->next = dgap_newnode(MNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - if (linecnt) - brd->u.board.module2++; - else - brd->u.board.module1++; - - DPR_INIT(("Adding MOD to config...\n")); - break; - - case PORTS: /* ports type EBI module */ - if (p->type != MNODE) { - dgap_err("ports only valid for EBI modules"); - return(-1); - } - p->u.module.type = PORTS; - p->u.module.v_type = 1; - DPR_INIT(("Adding PORTS to config...\n")); - break; - - case MODEM: /* ports type EBI module */ - if (p->type != MNODE) { - dgap_err("modem only valid for modem modules"); - return(-1); - } - p->u.module.type = MODEM; - p->u.module.v_type = 1; - DPR_INIT(("Adding MODEM to config...\n")); - break; - - case CABLE: - if (p->type == LNODE) { - if ((s = dgap_getword(in)) == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.line.cable = dgap_savestring(s); - p->u.line.v_cable = 1; - } - DPR_INIT(("Adding CABLE (%s) to config...\n", s)); - break; - - case SPEED: /* sync line speed indication */ - if (p->type == LNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.line.speed = (char)simple_strtol(s, &s2, 0); - if ((short)strlen(s) > (short)(s2 - s)) { - dgap_err("bad number for line speed"); - return(-1); - } - p->u.line.v_speed = 1; - } else if (p->type == CNODE) { - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.conc.speed = (char)simple_strtol(s, &s2, 0); - if ((short)strlen(s) > (short)(s2 - s)) { - dgap_err("bad number for line speed"); - return(-1); - } - p->u.conc.v_speed = 1; - } else { - dgap_err("speed valid only for lines or concentrators."); - return(-1); - } - DPR_INIT(("Adding SPEED (%s) to config...\n", s)); - break; - - case CONNECT: - if (p->type == CNODE) { - if ((s = dgap_getword(in)) == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.conc.connect = dgap_savestring(s); - p->u.conc.v_connect = 1; - } - DPR_INIT(("Adding CONNECT (%s) to config...\n", s)); - break; - case PRINT: /* transparent print name prefix */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(PNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - if ( (s = dgap_getword(in)) == NULL ) { - dgap_err("unexpeced end of file"); - return(-1); - } - if ( (p->u.printname = dgap_savestring(s)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - DPR_INIT(("Adding PRINT (%s) to config...\n", s)); - break; - - case CMAJOR: /* major number */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(JNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.majornumber = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for major number"); - return(-1); - } - DPR_INIT(("Adding CMAJOR (%s) to config...\n", s)); - break; - - case ALTPIN: /* altpin setting */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(ANODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.altpin = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for altpin"); - return(-1); - } - DPR_INIT(("Adding ALTPIN (%s) to config...\n", s)); - break; - - case USEINTR: /* enable interrupt setting */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(INTRNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.useintr = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for useintr"); - return(-1); - } - DPR_INIT(("Adding USEINTR (%s) to config...\n", s)); - break; - - case TTSIZ: /* size of tty structure */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(TSNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.ttysize = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for ttysize"); - return(-1); - } - DPR_INIT(("Adding TTSIZ (%s) to config...\n", s)); - break; - - case CHSIZ: /* channel structure size */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(CSNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.chsize = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for chsize"); - return(-1); - } - DPR_INIT(("Adding CHSIZE (%s) to config...\n", s)); - break; - - case BSSIZ: /* board structure size */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(BSNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.bssize = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for bssize"); - return(-1); - } - DPR_INIT(("Adding BSSIZ (%s) to config...\n", s)); - break; - - case UNTSIZ: /* sched structure size */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(USNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.unsize = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for schedsize"); - return(-1); - } - DPR_INIT(("Adding UNTSIZ (%s) to config...\n", s)); - break; - - case F2SIZ: /* f2200 structure size */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(FSNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.f2size = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for f2200size"); - return(-1); - } - DPR_INIT(("Adding F2SIZ (%s) to config...\n", s)); - break; - - case VPSIZ: /* vpix structure size */ - if (dgap_checknode(p)) - return(-1); - if ( (p->next = dgap_newnode(VSNODE)) == NULL ) { - dgap_err("out of memory"); - return(-1); - } - p = p->next; - s = dgap_getword(in); - if (s == NULL) { - dgap_err("unexpected end of file"); - return(-1); - } - p->u.vpixsize = simple_strtol(s, &s2, 0); - if ((int)strlen(s) > (int)(s2 - s)) { - dgap_err("bad number for vpixsize"); - return(-1); - } - DPR_INIT(("Adding VPSIZ (%s) to config...\n", s)); - break; - } - } -} - - -/* - * 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. - */ -static char *dgap_sindex (char *string, char *group) -{ - char *ptr; - - if (!string || !group) - return (char *) NULL; - - if (*group == '^') { - group++; - for (; *string; string++) { - for (ptr = group; *ptr; ptr++) { - if (*ptr == *string) - break; - } - if (*ptr == '\0') - return string; - } - } - else { - for (; *string; string++) { - for (ptr = group; *ptr; ptr++) { - if (*ptr == *string) - return string; - } - } - } - - return (char *) NULL; -} - - -/* - * Get a token from the input file; return 0 if end of file is reached - */ -static int dgap_gettok(char **in, struct cnode *p) -{ - char *w; - struct toklist *t; - - if (strstr(dgap_cword, "boar")) { - w = dgap_getword(in); - snprintf(dgap_cword, MAXCWORD, "%s", w); - for (t = dgap_tlist; t->token != 0; t++) { - if ( !strcmp(w, t->string)) { - return(t->token); - } - } - dgap_err("board !!type not specified"); - return(1); - } - else { - while ( (w = dgap_getword(in)) != NULL ) { - snprintf(dgap_cword, MAXCWORD, "%s", w); - for (t = dgap_tlist; t->token != 0; t++) { - if ( !strcmp(w, t->string) ) - return(t->token); - } - } - return(0); - } -} - - -/* - * get a word from the input stream, also keep track of current line number. - * words are separated by whitespace. - */ -static char *dgap_getword(char **in) -{ - char *ret_ptr = *in; - - char *ptr = dgap_sindex(*in, " \t\n"); - - /* If no word found, return null */ - if (!ptr) - return NULL; - - /* Mark new location for our buffer */ - *ptr = '\0'; - *in = ptr + 1; - - /* Eat any extra spaces/tabs/newlines that might be present */ - while (*in && **in && ((**in == ' ') || (**in == '\t') || (**in == '\n'))) { - **in = '\0'; - *in = *in + 1; - } - - return ret_ptr; -} - - -/* - * print an error message, giving the line number in the file where - * the error occurred. - */ -static void dgap_err(char *s) -{ - printk("DGAP: parse: %s\n", s); -} - - -/* - * allocate a new configuration node of type t - */ -static struct cnode *dgap_newnode(int t) -{ - struct cnode *n; - - n = kmalloc(sizeof(struct cnode), GFP_ATOMIC); - if (n != NULL) { - memset((char *)n, 0, sizeof(struct cnode)); - n->type = t; - } - return(n); -} - - -/* - * dgap_checknode: see if all the necessary info has been supplied for a node - * before creating the next node. - */ -static int dgap_checknode(struct cnode *p) -{ - switch (p->type) { - case BNODE: - if (p->u.board.v_type == 0) { - dgap_err("board type !not specified"); - return(1); - } - - return(0); - - case LNODE: - if (p->u.line.v_speed == 0) { - dgap_err("line speed not specified"); - return(1); - } - return(0); - - case CNODE: - if (p->u.conc.v_type == 0) { - dgap_err("concentrator type not specified"); - return(1); - } - if (p->u.conc.v_speed == 0) { - dgap_err("concentrator line speed not specified"); - return(1); - } - if (p->u.conc.v_nport == 0) { - dgap_err("number of ports on concentrator not specified"); - return(1); - } - if (p->u.conc.v_id == 0) { - dgap_err("concentrator id letter not specified"); - return(1); - } - return(0); - - case MNODE: - if (p->u.module.v_type == 0) { - dgap_err("EBI module type not specified"); - return(1); - } - if (p->u.module.v_nport == 0) { - dgap_err("number of ports on EBI module not specified"); - return(1); - } - if (p->u.module.v_id == 0) { - dgap_err("EBI module id letter not specified"); - return(1); - } - return(0); - } - return(0); -} - -/* - * save a string somewhere - */ -static char *dgap_savestring(char *s) -{ - char *p; - if ( (p = kmalloc(strlen(s) + 1, GFP_ATOMIC) ) != NULL) { - strcpy(p, s); - } - return(p); -} - - -/* - * Given a board pointer, returns whether we should use interrupts or not. - */ -uint dgap_config_get_useintr(struct board_t *bd) -{ - struct cnode *p = NULL; - - if (!bd) - return(0); - - for (p = bd->bd_config; p; p = p->next) { - switch (p->type) { - case INTRNODE: - /* - * check for pcxr types. - */ - return p->u.useintr; - default: - break; - } - } - - /* If not found, then don't turn on interrupts. */ - return 0; -} - - -/* - * Given a board pointer, returns whether we turn on altpin or not. - */ -uint dgap_config_get_altpin(struct board_t *bd) -{ - struct cnode *p = NULL; - - if (!bd) - return(0); - - for (p = bd->bd_config; p; p = p->next) { - switch (p->type) { - case ANODE: - /* - * check for pcxr types. - */ - return p->u.altpin; - default: - break; - } - } - - /* If not found, then don't turn on interrupts. */ - return 0; -} - - - -/* - * Given a specific type of board, if found, detached link and - * returns the first occurrence in the list. - */ -struct cnode *dgap_find_config(int type, int bus, int slot) -{ - struct cnode *p, *prev = NULL, *prev2 = NULL, *found = NULL; - - p = &dgap_head; - - while (p->next != NULL) { - prev = p; - p = p->next; - - if (p->type == BNODE) { - - if (p->u.board.type == type) { - - if (p->u.board.v_pcibus && p->u.board.pcibus != bus) { - DPR(("Found matching board, but wrong bus position. System says bus %d, we want bus %ld\n", - bus, p->u.board.pcibus)); - continue; - } - if (p->u.board.v_pcislot && p->u.board.pcislot != slot) { - DPR_INIT(("Found matching board, but wrong slot position. System says slot %d, we want slot %ld\n", - slot, p->u.board.pcislot)); - continue; - } - - DPR_INIT(("Matched type in config file\n")); - - found = p; - /* - * Keep walking thru the list till we find the next board. - */ - while (p->next != NULL) { - prev2 = p; - p = p->next; - if (p->type == BNODE) { - - /* - * Mark the end of our 1 board chain of configs. - */ - prev2->next = NULL; - - /* - * Link the "next" board to the previous board, - * effectively "unlinking" our board from the main config. - */ - prev->next = p; - - return found; - } - } - /* - * It must be the last board in the list. - */ - prev->next = NULL; - return found; - } - } - } - return NULL; -} - -/* - * Given a board pointer, walks the config link, counting up - * all ports user specified should be on the board. - * (This does NOT mean they are all actually present right now tho) - */ -uint dgap_config_get_number_of_ports(struct board_t *bd) -{ - int count = 0; - struct cnode *p = NULL; - - if (!bd) - return(0); - - for (p = bd->bd_config; p; p = p->next) { - - switch (p->type) { - case BNODE: - /* - * check for pcxr types. - */ - if (p->u.board.type > EPCFE) - count += p->u.board.nport; - break; - case CNODE: - count += p->u.conc.nport; - break; - case MNODE: - count += p->u.module.nport; - break; - } - } - return (count); -} - -char *dgap_create_config_string(struct board_t *bd, char *string) -{ - char *ptr = string; - struct cnode *p = NULL; - struct cnode *q = NULL; - int speed; - - if (!bd) { - *ptr = 0xff; - return string; - } - - for (p = bd->bd_config; p; p = p->next) { - - switch (p->type) { - case LNODE: - *ptr = '\0'; - ptr++; - *ptr = p->u.line.speed; - ptr++; - break; - case CNODE: - /* - * Because the EPC/con concentrators can have EM modules - * hanging off of them, we have to walk ahead in the list - * and keep adding the number of ports on each EM to the config. - * UGH! - */ - speed = p->u.conc.speed; - q = p->next; - if ((q != NULL) && (q->type == MNODE) ) { - *ptr = (p->u.conc.nport + 0x80); - ptr++; - p = q; - while ((q->next != NULL) && (q->next->type) == MNODE) { - *ptr = (q->u.module.nport + 0x80); - ptr++; - p = q; - q = q->next; - } - *ptr = q->u.module.nport; - ptr++; - } else { - *ptr = p->u.conc.nport; - ptr++; - } - - *ptr = speed; - ptr++; - break; - } - } - - *ptr = 0xff; - return string; -} - - - -char *dgap_get_config_letters(struct board_t *bd, char *string) -{ - int found = FALSE; - char *ptr = string; - struct cnode *cptr = NULL; - int len = 0; - int left = MAXTTYNAMELEN; - - if (!bd) { - return ""; - } - - for (cptr = bd->bd_config; cptr; cptr = cptr->next) { - - if ((cptr->type == BNODE) && - ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || - (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || - (cptr->u.board.type == PAPORT8))) { - - found = TRUE; - } - - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } - else { - ptr1 = cptr->u.ttyname; - } - if (ptr1) { - len = snprintf(ptr, left, "%s", ptr1); - left -= len; - ptr += len; - if (left <= 0) - break; - } - } - - if (cptr->type == CNODE) { - if (cptr->u.conc.id) { - len = snprintf(ptr, left, "%s", cptr->u.conc.id); - left -= len; - ptr += len; - if (left <= 0) - break; - } - } - - if (cptr->type == MNODE) { - if (cptr->u.module.id) { - len = snprintf(ptr, left, "%s", cptr->u.module.id); - left -= len; - ptr += len; - if (left <= 0) - break; - } - } - } - - return string; -} From 26e744a45ae046c7df9451bc152df4e134bf66ff Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:03 -0500 Subject: [PATCH 0439/1375] staging: dgap: Remove unneeded dgap_trace.c and dgap_trace.h Removes unneeded files dgap_trace.c and dgap_trace.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 3 +- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_trace.c | 185 ----------------------------- drivers/staging/dgap/dgap_trace.h | 35 ------ 4 files changed, 1 insertion(+), 223 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_trace.c delete mode 100644 drivers/staging/dgap/dgap_trace.h diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index 13bf6fb37379..b7b5778add17 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -1,6 +1,5 @@ obj-$(CONFIG_DGAP) += dgap.o -dgap-objs := dgap_driver.o \ - dgap_trace.o +dgap-objs := dgap_driver.o diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index cca35a0bf9e5..d1c539b0e501 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -55,7 +55,6 @@ #include "dgap_tty.h" #include "dgap_conf.h" #include "dgap_parse.h" -#include "dgap_trace.h" #include "dgap_sysfs.h" #include "dgap_types.h" diff --git a/drivers/staging/dgap/dgap_trace.c b/drivers/staging/dgap/dgap_trace.c deleted file mode 100644 index 3ffadcb6d6c5..000000000000 --- a/drivers/staging/dgap/dgap_trace.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - */ - - -#include -#include /* For jiffies, task states */ -#include /* For tasklet and interrupt structs/defines */ -#include - -#include "dgap_driver.h" -#include "dgap_trace.h" - -#define TRC_TO_CONSOLE 1 - -/* file level globals */ -static char *dgap_trcbuf; /* the ringbuffer */ - -#if defined(TRC_TO_KMEM) -static int dgap_trcbufi = 0; /* index of the tilde at the end of */ -#endif - -extern int dgap_trcbuf_size; /* size of the ringbuffer */ - -#if defined(TRC_TO_KMEM) -static DEFINE_SPINLOCK(dgap_tracef_lock); -#endif - -#if 0 - -#if !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) -void dgap_tracef(const char *fmt, ...) -{ - return; -} - -#else /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */ - -void dgap_tracef(const char *fmt, ...) -{ - va_list ap; - char buf[TRC_MAXMSG+1]; - size_t lenbuf; - int i; - static int failed = FALSE; -# if defined(TRC_TO_KMEM) - unsigned long flags; -#endif - - if(failed) - return; -# if defined(TRC_TO_KMEM) - DGAP_LOCK(dgap_tracef_lock, flags); -#endif - - /* Format buf using fmt and arguments contained in ap. */ - va_start(ap, fmt); - i = vsprintf(buf, fmt, ap); - va_end(ap); - lenbuf = strlen(buf); - -# if defined(TRC_TO_KMEM) - { - static int initd=0; - - /* - * Now, in addition to (or instead of) printing this stuff out - * (which is a buffered operation), also tuck it away into a - * corner of memory which can be examined post-crash in kdb. - */ - if (!initd) { - dgap_trcbuf = (char *) vmalloc(dgap_trcbuf_size); - if(!dgap_trcbuf) { - failed = TRUE; - printk("dgap: tracing init failed!\n"); - return; - } - - memset(dgap_trcbuf, '\0', dgap_trcbuf_size); - dgap_trcbufi = 0; - initd++; - - printk("dgap: tracing enabled - " TRC_DTRC - " 0x%lx 0x%x\n", - (unsigned long)dgap_trcbuf, - dgap_trcbuf_size); - } - -# if defined(TRC_ON_OVERFLOW_WRAP_AROUND) - /* - * This is the less CPU-intensive way to do things. We simply - * wrap around before we fall off the end of the buffer. A - * tilde (~) demarcates the current end of the trace. - * - * This method should be used if you are concerned about race - * conditions as it is less likely to affect the timing of - * things. - */ - - if (dgap_trcbufi + lenbuf >= dgap_trcbuf_size) { - /* We are wrapping, so wipe out the last tilde. */ - dgap_trcbuf[dgap_trcbufi] = '\0'; - /* put the new string at the beginning of the buffer */ - dgap_trcbufi = 0; - } - - strcpy(&dgap_trcbuf[dgap_trcbufi], buf); - dgap_trcbufi += lenbuf; - dgap_trcbuf[dgap_trcbufi] = '~'; - -# elif defined(TRC_ON_OVERFLOW_SHIFT_BUFFER) - /* - * This is the more CPU-intensive way to do things. If we - * venture into the last 1/8 of the buffer, we shift the - * last 7/8 of the buffer forward, wiping out the first 1/8. - * Advantage: No wrap-around, only truncation from the - * beginning. - * - * This method should not be used if you are concerned about - * timing changes affecting the behaviour of the driver (ie, - * race conditions). - */ - strcpy(&dgap_trcbuf[dgap_trcbufi], buf); - dgap_trcbufi += lenbuf; - dgap_trcbuf[dgap_trcbufi] = '~'; - dgap_trcbuf[dgap_trcbufi+1] = '\0'; - - /* If we're near the end of the trace buffer... */ - if (dgap_trcbufi > (dgap_trcbuf_size/8)*7) { - /* Wipe out the first eighth to make some more room. */ - strcpy(dgap_trcbuf, &dgap_trcbuf[dgap_trcbuf_size/8]); - dgap_trcbufi = strlen(dgap_trcbuf)-1; - /* Plop overflow message at the top of the buffer. */ - bcopy(TRC_OVERFLOW, dgap_trcbuf, strlen(TRC_OVERFLOW)); - } -# else -# error "TRC_ON_OVERFLOW_WRAP_AROUND or TRC_ON_OVERFLOW_SHIFT_BUFFER?" -# endif - } - DGAP_UNLOCK(dgap_tracef_lock, flags); - -# endif /* defined(TRC_TO_KMEM) */ -} - -#endif /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */ - -#endif - -/* - * dgap_tracer_free() - * - * - */ -void dgap_tracer_free(void) -{ - if(dgap_trcbuf) - vfree(dgap_trcbuf); -} diff --git a/drivers/staging/dgap/dgap_trace.h b/drivers/staging/dgap/dgap_trace.h deleted file mode 100644 index 47ef0088c4b0..000000000000 --- a/drivers/staging/dgap/dgap_trace.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - * - ***************************************************************************** - * Header file for dgap_trace.c - * - */ - -#ifndef __DGAP_TRACE_H -#define __DGAP_TRACE_H - -#include "dgap_driver.h" - -void dgap_tracef(const char *fmt, ...); -void dgap_tracer_free(void); - -#endif - From 4aeafa876132848ffcd958baf77f2716ccf5c9f2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:04 -0500 Subject: [PATCH 0440/1375] staging: dgap: Merge dgap_tty.h into dgap_driver.c There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 9 ++++++- drivers/staging/dgap/dgap_tty.h | 39 ------------------------------ 2 files changed, 8 insertions(+), 40 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_tty.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index d1c539b0e501..1f93066c9df3 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -52,7 +52,6 @@ #include "dgap_driver.h" #include "dgap_pci.h" #include "dgap_fep5.h" -#include "dgap_tty.h" #include "dgap_conf.h" #include "dgap_parse.h" #include "dgap_sysfs.h" @@ -129,6 +128,14 @@ static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c); static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); +int dgap_tty_register(struct board_t *brd); +int dgap_tty_preinit(void); +int dgap_tty_init(struct board_t *); +void dgap_tty_post_uninit(void); +void dgap_tty_uninit(struct board_t *); +void dgap_carrier(struct channel_t *ch); +void dgap_input(struct channel_t *ch); + /* * Our function prototypes from dgap_fep5 */ diff --git a/drivers/staging/dgap/dgap_tty.h b/drivers/staging/dgap/dgap_tty.h deleted file mode 100644 index 464a460b6be8..000000000000 --- a/drivers/staging/dgap/dgap_tty.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef __DGAP_TTY_H -#define __DGAP_TTY_H - -#include "dgap_driver.h" - -int dgap_tty_register(struct board_t *brd); - -int dgap_tty_preinit(void); -int dgap_tty_init(struct board_t *); - -void dgap_tty_post_uninit(void); -void dgap_tty_uninit(struct board_t *); - -void dgap_carrier(struct channel_t *ch); -void dgap_input(struct channel_t *ch); - - -#endif From 30580a78a9faf05f57c74c1166ed6399db58aef9 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:05 -0500 Subject: [PATCH 0441/1375] staging: dgap: Merge dgap_sysfs.h into dgap_driver.c There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 22 +++++++++++++- drivers/staging/dgap/dgap_driver.h | 1 - drivers/staging/dgap/dgap_sysfs.h | 48 ------------------------------ 3 files changed, 21 insertions(+), 50 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_sysfs.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 1f93066c9df3..6b1ff66005b7 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -54,7 +54,6 @@ #include "dgap_fep5.h" #include "dgap_conf.h" #include "dgap_parse.h" -#include "dgap_sysfs.h" #include "dgap_types.h" #define init_MUTEX(sem) sema_init(sem, 1) @@ -152,6 +151,27 @@ static struct cnode *dgap_newnode(int t); static int dgap_checknode(struct cnode *p); static void dgap_err(char *s); +/* + * Function prototypes from dgap_sysfs.h + */ +struct board_t; +struct channel_t; +struct un_t; +struct pci_driver; +struct class_device; + +void dgap_create_ports_sysfiles(struct board_t *bd); +void dgap_remove_ports_sysfiles(struct board_t *bd); + +void dgap_create_driver_sysfiles(struct pci_driver *); +void dgap_remove_driver_sysfiles(struct pci_driver *); + +int dgap_tty_class_init(void); +int dgap_tty_class_destroy(void); + +void dgap_create_tty_sysfs(struct un_t *un, struct device *c); +void dgap_remove_tty_sysfs(struct device *c); + /* Driver load/unload functions */ int dgap_init_module(void); void dgap_cleanup_module(void); diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 9296adcb06c9..640c46d14131 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -34,7 +34,6 @@ #include "dgap_types.h" /* Additional types needed by the Digi header files */ #include "digi.h" /* Digi specific ioctl header */ #include "dgap_kcompat.h" /* Kernel 2.4/2.6 compat includes */ -#include "dgap_sysfs.h" /* Support for SYSFS */ /************************************************************************* * diff --git a/drivers/staging/dgap/dgap_sysfs.h b/drivers/staging/dgap/dgap_sysfs.h deleted file mode 100644 index 151f1b32c76b..000000000000 --- a/drivers/staging/dgap/dgap_sysfs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef __DGAP_SYSFS_H -#define __DGAP_SYSFS_H - -#include "dgap_driver.h" - -#include - -struct board_t; -struct channel_t; -struct un_t; -struct pci_driver; -struct class_device; - -extern void dgap_create_ports_sysfiles(struct board_t *bd); -extern void dgap_remove_ports_sysfiles(struct board_t *bd); - -extern void dgap_create_driver_sysfiles(struct pci_driver *); -extern void dgap_remove_driver_sysfiles(struct pci_driver *); - -extern int dgap_tty_class_init(void); -extern int dgap_tty_class_destroy(void); - -extern void dgap_create_tty_sysfs(struct un_t *un, struct device *c); -extern void dgap_remove_tty_sysfs(struct device *c); - - -#endif From fec6c4e0e7967ad67b7f97fa3183b33bf794b3e6 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:06 -0500 Subject: [PATCH 0442/1375] staging: dgap: Merge dgap_fep5.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_driver.h | 222 +++++++++++++++++++++++++ drivers/staging/dgap/dgap_fep5.h | 253 ----------------------------- 3 files changed, 222 insertions(+), 254 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_fep5.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 6b1ff66005b7..bba9fac50d26 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -51,7 +51,6 @@ #include "dgap_driver.h" #include "dgap_pci.h" -#include "dgap_fep5.h" #include "dgap_conf.h" #include "dgap_parse.h" #include "dgap_types.h" diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 640c46d14131..8bd6416f274c 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -238,6 +238,119 @@ # define DGAP_UNLOCK(x,y) spin_unlock_irqrestore(&(x), y) # define DGAP_TRYLOCK(x,y) spin_trylock(&(x)) +/************************************************************************ + * FEP memory offsets + ************************************************************************/ +#define START 0x0004L /* Execution start address */ + +#define CMDBUF 0x0d10L /* Command (cm_t) structure offset */ +#define CMDSTART 0x0400L /* Start of command buffer */ +#define CMDMAX 0x0800L /* End of command buffer */ + +#define EVBUF 0x0d18L /* Event (ev_t) structure */ +#define EVSTART 0x0800L /* Start of event buffer */ +#define EVMAX 0x0c00L /* End of event buffer */ +#define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ +#define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ +#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ + /* if the fep has extended capabilities */ + +/* BIOS MAGIC SPOTS */ +#define ERROR 0x0C14L /* BIOS error code */ +#define SEQUENCE 0x0C12L /* BIOS sequence indicator */ +#define POSTAREA 0x0C00L /* POST complete message area */ + +/* FEP MAGIC SPOTS */ +#define FEPSTAT POSTAREA /* OS here when FEP comes up */ +#define NCHAN 0x0C02L /* number of ports FEP sees */ +#define PANIC 0x0C10L /* PANIC area for FEP */ +#define KMEMEM 0x0C30L /* Memory for KME use */ +#define CONFIG 0x0CD0L /* Concentrator configuration info */ +#define CONFIGSIZE 0x0030 /* configuration info size */ +#define DOWNREQ 0x0D00 /* Download request buffer pointer */ + +#define CHANBUF 0x1000L /* Async channel (bs_t) structs */ +#define FEPOSSIZE 0x1FFF /* 8K FEPOS */ + +#define XEMPORTS 0xC02 /* + * Offset in board memory where FEP5 stores + * how many ports it has detected. + * NOTE: FEP5 reports 64 ports when the user + * has the cable in EBI OUT instead of EBI IN. + */ + +#define FEPCLR 0x00 +#define FEPMEM 0x02 +#define FEPRST 0x04 +#define FEPINT 0x08 +#define FEPMASK 0x0e +#define FEPWIN 0x80 + +#define LOWMEM 0x0100 +#define HIGHMEM 0x7f00 + +#define FEPTIMEOUT 200000 + +#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ +#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ +#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ +#define FEPPOLL 0x0c26 /* Fep event poll interval */ + +#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ + +/************************************************************************ + * FEP supported functions + ************************************************************************/ +#define SRLOW 0xe0 /* Set receive low water */ +#define SRHIGH 0xe1 /* Set receive high water */ +#define FLUSHTX 0xe2 /* Flush transmit buffer */ +#define PAUSETX 0xe3 /* Pause data transmission */ +#define RESUMETX 0xe4 /* Resume data transmission */ +#define SMINT 0xe5 /* Set Modem Interrupt */ +#define SAFLOWC 0xe6 /* Set Aux. flow control chars */ +#define SBREAK 0xe8 /* Send break */ +#define SMODEM 0xe9 /* Set 8530 modem control lines */ +#define SIFLAG 0xea /* Set UNIX iflags */ +#define SFLOWC 0xeb /* Set flow control characters */ +#define STLOW 0xec /* Set transmit low water mark */ +#define RPAUSE 0xee /* Pause receive */ +#define RRESUME 0xef /* Resume receive */ +#define CHRESET 0xf0 /* Reset Channel */ +#define BUFSETALL 0xf2 /* Set Tx & Rx buffer size avail*/ +#define SOFLAG 0xf3 /* Set UNIX oflags */ +#define SHFLOW 0xf4 /* Set hardware handshake */ +#define SCFLAG 0xf5 /* Set UNIX cflags */ +#define SVNEXT 0xf6 /* Set VNEXT character */ +#define SPINTFC 0xfc /* Reserved */ +#define SCOMMODE 0xfd /* Set RS232/422 mode */ + + +/************************************************************************ + * Modes for SCOMMODE + ************************************************************************/ +#define MODE_232 0x00 +#define MODE_422 0x01 + + +/************************************************************************ + * Event flags. + ************************************************************************/ +#define IFBREAK 0x01 /* Break received */ +#define IFTLW 0x02 /* Transmit low water */ +#define IFTEM 0x04 /* Transmitter empty */ +#define IFDATA 0x08 /* Receive data present */ +#define IFMODEM 0x20 /* Modem status change */ + +/************************************************************************ + * Modem flags + ************************************************************************/ +# define DM_RTS 0x02 /* Request to send */ +# define DM_CD 0x80 /* Carrier detect */ +# define DM_DSR 0x20 /* Data set ready */ +# define DM_CTS 0x10 /* Clear to send */ +# define DM_RI 0x40 /* Ring indicator */ +# define DM_DTR 0x01 /* Data terminal ready */ + /* * All the possible states the driver can be while being loaded. */ @@ -564,6 +677,115 @@ struct channel_t { wait_queue_head_t ch_sniff_wait; }; +/************************************************************************ + * Command structure definition. + ************************************************************************/ +struct cm_t { + volatile unsigned short cm_head; /* Command buffer head offset */ + volatile unsigned short cm_tail; /* Command buffer tail offset */ + volatile unsigned short cm_start; /* start offset of buffer */ + volatile unsigned short cm_max; /* last offset of buffer */ +}; + +/************************************************************************ + * Event structure definition. + ************************************************************************/ +struct ev_t { + volatile unsigned short ev_head; /* Command buffer head offset */ + volatile unsigned short ev_tail; /* Command buffer tail offset */ + volatile unsigned short ev_start; /* start offset of buffer */ + volatile unsigned short ev_max; /* last offset of buffer */ +}; + +/************************************************************************ + * Download buffer structure. + ************************************************************************/ +struct downld_t { + uchar dl_type; /* Header */ + uchar dl_seq; /* Download sequence */ + ushort dl_srev; /* Software revision number */ + ushort dl_lrev; /* Low revision number */ + ushort dl_hrev; /* High revision number */ + ushort dl_seg; /* Start segment address */ + ushort dl_size; /* Number of bytes to download */ + uchar dl_data[1024]; /* Download data */ +}; + +/************************************************************************ + * Per channel buffer structure + ************************************************************************ + * Base Structure Entries Usage Meanings to Host * + * * + * W = read write R = read only * + * C = changed by commands only * + * U = unknown (may be changed w/o notice) * + ************************************************************************/ +struct bs_t { + volatile unsigned short tp_jmp; /* Transmit poll jump */ + volatile unsigned short tc_jmp; /* Cooked procedure jump */ + volatile unsigned short ri_jmp; /* Not currently used */ + volatile unsigned short rp_jmp; /* Receive poll jump */ + + volatile unsigned short tx_seg; /* W Tx segment */ + volatile unsigned short tx_head; /* W Tx buffer head offset */ + volatile unsigned short tx_tail; /* R Tx buffer tail offset */ + volatile unsigned short tx_max; /* W Tx buffer size - 1 */ + + volatile unsigned short rx_seg; /* W Rx segment */ + volatile unsigned short rx_head; /* W Rx buffer head offset */ + volatile unsigned short rx_tail; /* R Rx buffer tail offset */ + volatile unsigned short rx_max; /* W Rx buffer size - 1 */ + + volatile unsigned short tx_lw; /* W Tx buffer low water mark */ + volatile unsigned short rx_lw; /* W Rx buffer low water mark */ + volatile unsigned short rx_hw; /* W Rx buffer high water mark */ + volatile unsigned short incr; /* W Increment to next channel */ + + volatile unsigned short fepdev; /* U SCC device base address */ + volatile unsigned short edelay; /* W Exception delay */ + volatile unsigned short blen; /* W Break length */ + volatile unsigned short btime; /* U Break complete time */ + + volatile unsigned short iflag; /* C UNIX input flags */ + volatile unsigned short oflag; /* C UNIX output flags */ + volatile unsigned short cflag; /* C UNIX control flags */ + volatile unsigned short wfill[13]; /* U Reserved for expansion */ + + volatile unsigned char num; /* U Channel number */ + volatile unsigned char ract; /* U Receiver active counter */ + volatile unsigned char bstat; /* U Break status bits */ + volatile unsigned char tbusy; /* W Transmit busy */ + volatile unsigned char iempty; /* W Transmit empty event enable */ + volatile unsigned char ilow; /* W Transmit low-water event enable */ + volatile unsigned char idata; /* W Receive data interrupt enable */ + volatile unsigned char eflag; /* U Host event flags */ + + volatile unsigned char tflag; /* U Transmit flags */ + volatile unsigned char rflag; /* U Receive flags */ + volatile unsigned char xmask; /* U Transmit ready flags */ + volatile unsigned char xval; /* U Transmit ready value */ + volatile unsigned char m_stat; /* RC Modem status bits */ + volatile unsigned char m_change; /* U Modem bits which changed */ + volatile unsigned char m_int; /* W Modem interrupt enable bits */ + volatile unsigned char m_last; /* U Last modem status */ + + volatile unsigned char mtran; /* C Unreported modem trans */ + volatile unsigned char orun; /* C Buffer overrun occurred */ + volatile unsigned char astartc; /* W Auxiliary Xon char */ + volatile unsigned char astopc; /* W Auxiliary Xoff char */ + volatile unsigned char startc; /* W Xon character */ + volatile unsigned char stopc; /* W Xoff character */ + volatile unsigned char vnextc; /* W Vnext character */ + volatile unsigned char hflow; /* C Software flow control */ + + volatile unsigned char fillc; /* U Delay Fill character */ + volatile unsigned char ochar; /* U Saved output character */ + volatile unsigned char omask; /* U Output character mask */ + + volatile unsigned char bfill[13]; /* U Reserved for expansion */ + + volatile unsigned char scc[16]; /* U SCC registers */ +}; /************************************************************************* * diff --git a/drivers/staging/dgap/dgap_fep5.h b/drivers/staging/dgap/dgap_fep5.h deleted file mode 100644 index d0650ae2dd51..000000000000 --- a/drivers/staging/dgap/dgap_fep5.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - * - ************************************************************************ - *** FEP Version 5 dependent definitions - ************************************************************************/ - -#ifndef __DGAP_FEP5_H -#define __DGAP_FEP5_H - -/************************************************************************ - * FEP memory offsets - ************************************************************************/ -#define START 0x0004L /* Execution start address */ - -#define CMDBUF 0x0d10L /* Command (cm_t) structure offset */ -#define CMDSTART 0x0400L /* Start of command buffer */ -#define CMDMAX 0x0800L /* End of command buffer */ - -#define EVBUF 0x0d18L /* Event (ev_t) structure */ -#define EVSTART 0x0800L /* Start of event buffer */ -#define EVMAX 0x0c00L /* End of event buffer */ -#define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ -#define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ -#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ - /* if the fep has extended capabilities */ - -/* BIOS MAGIC SPOTS */ -#define ERROR 0x0C14L /* BIOS error code */ -#define SEQUENCE 0x0C12L /* BIOS sequence indicator */ -#define POSTAREA 0x0C00L /* POST complete message area */ - -/* FEP MAGIC SPOTS */ -#define FEPSTAT POSTAREA /* OS here when FEP comes up */ -#define NCHAN 0x0C02L /* number of ports FEP sees */ -#define PANIC 0x0C10L /* PANIC area for FEP */ -#define KMEMEM 0x0C30L /* Memory for KME use */ -#define CONFIG 0x0CD0L /* Concentrator configuration info */ -#define CONFIGSIZE 0x0030 /* configuration info size */ -#define DOWNREQ 0x0D00 /* Download request buffer pointer */ - -#define CHANBUF 0x1000L /* Async channel (bs_t) structs */ -#define FEPOSSIZE 0x1FFF /* 8K FEPOS */ - -#define XEMPORTS 0xC02 /* - * Offset in board memory where FEP5 stores - * how many ports it has detected. - * NOTE: FEP5 reports 64 ports when the user - * has the cable in EBI OUT instead of EBI IN. - */ - -#define FEPCLR 0x00 -#define FEPMEM 0x02 -#define FEPRST 0x04 -#define FEPINT 0x08 -#define FEPMASK 0x0e -#define FEPWIN 0x80 - -#define LOWMEM 0x0100 -#define HIGHMEM 0x7f00 - -#define FEPTIMEOUT 200000 - -#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ -#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ -#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ -#define FEPPOLL 0x0c26 /* Fep event poll interval */ - -#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ - -/************************************************************************ - * Command structure definition. - ************************************************************************/ -struct cm_t { - volatile unsigned short cm_head; /* Command buffer head offset */ - volatile unsigned short cm_tail; /* Command buffer tail offset */ - volatile unsigned short cm_start; /* start offset of buffer */ - volatile unsigned short cm_max; /* last offset of buffer */ -}; - -/************************************************************************ - * Event structure definition. - ************************************************************************/ -struct ev_t { - volatile unsigned short ev_head; /* Command buffer head offset */ - volatile unsigned short ev_tail; /* Command buffer tail offset */ - volatile unsigned short ev_start; /* start offset of buffer */ - volatile unsigned short ev_max; /* last offset of buffer */ -}; - -/************************************************************************ - * Download buffer structure. - ************************************************************************/ -struct downld_t { - uchar dl_type; /* Header */ - uchar dl_seq; /* Download sequence */ - ushort dl_srev; /* Software revision number */ - ushort dl_lrev; /* Low revision number */ - ushort dl_hrev; /* High revision number */ - ushort dl_seg; /* Start segment address */ - ushort dl_size; /* Number of bytes to download */ - uchar dl_data[1024]; /* Download data */ -}; - -/************************************************************************ - * Per channel buffer structure - ************************************************************************ - * Base Structure Entries Usage Meanings to Host * - * * - * W = read write R = read only * - * C = changed by commands only * - * U = unknown (may be changed w/o notice) * - ************************************************************************/ -struct bs_t { - volatile unsigned short tp_jmp; /* Transmit poll jump */ - volatile unsigned short tc_jmp; /* Cooked procedure jump */ - volatile unsigned short ri_jmp; /* Not currently used */ - volatile unsigned short rp_jmp; /* Receive poll jump */ - - volatile unsigned short tx_seg; /* W Tx segment */ - volatile unsigned short tx_head; /* W Tx buffer head offset */ - volatile unsigned short tx_tail; /* R Tx buffer tail offset */ - volatile unsigned short tx_max; /* W Tx buffer size - 1 */ - - volatile unsigned short rx_seg; /* W Rx segment */ - volatile unsigned short rx_head; /* W Rx buffer head offset */ - volatile unsigned short rx_tail; /* R Rx buffer tail offset */ - volatile unsigned short rx_max; /* W Rx buffer size - 1 */ - - volatile unsigned short tx_lw; /* W Tx buffer low water mark */ - volatile unsigned short rx_lw; /* W Rx buffer low water mark */ - volatile unsigned short rx_hw; /* W Rx buffer high water mark */ - volatile unsigned short incr; /* W Increment to next channel */ - - volatile unsigned short fepdev; /* U SCC device base address */ - volatile unsigned short edelay; /* W Exception delay */ - volatile unsigned short blen; /* W Break length */ - volatile unsigned short btime; /* U Break complete time */ - - volatile unsigned short iflag; /* C UNIX input flags */ - volatile unsigned short oflag; /* C UNIX output flags */ - volatile unsigned short cflag; /* C UNIX control flags */ - volatile unsigned short wfill[13]; /* U Reserved for expansion */ - - volatile unsigned char num; /* U Channel number */ - volatile unsigned char ract; /* U Receiver active counter */ - volatile unsigned char bstat; /* U Break status bits */ - volatile unsigned char tbusy; /* W Transmit busy */ - volatile unsigned char iempty; /* W Transmit empty event enable */ - volatile unsigned char ilow; /* W Transmit low-water event enable */ - volatile unsigned char idata; /* W Receive data interrupt enable */ - volatile unsigned char eflag; /* U Host event flags */ - - volatile unsigned char tflag; /* U Transmit flags */ - volatile unsigned char rflag; /* U Receive flags */ - volatile unsigned char xmask; /* U Transmit ready flags */ - volatile unsigned char xval; /* U Transmit ready value */ - volatile unsigned char m_stat; /* RC Modem status bits */ - volatile unsigned char m_change; /* U Modem bits which changed */ - volatile unsigned char m_int; /* W Modem interrupt enable bits */ - volatile unsigned char m_last; /* U Last modem status */ - - volatile unsigned char mtran; /* C Unreported modem trans */ - volatile unsigned char orun; /* C Buffer overrun occurred */ - volatile unsigned char astartc; /* W Auxiliary Xon char */ - volatile unsigned char astopc; /* W Auxiliary Xoff char */ - volatile unsigned char startc; /* W Xon character */ - volatile unsigned char stopc; /* W Xoff character */ - volatile unsigned char vnextc; /* W Vnext character */ - volatile unsigned char hflow; /* C Software flow control */ - - volatile unsigned char fillc; /* U Delay Fill character */ - volatile unsigned char ochar; /* U Saved output character */ - volatile unsigned char omask; /* U Output character mask */ - - volatile unsigned char bfill[13]; /* U Reserved for expansion */ - - volatile unsigned char scc[16]; /* U SCC registers */ -}; - - -/************************************************************************ - * FEP supported functions - ************************************************************************/ -#define SRLOW 0xe0 /* Set receive low water */ -#define SRHIGH 0xe1 /* Set receive high water */ -#define FLUSHTX 0xe2 /* Flush transmit buffer */ -#define PAUSETX 0xe3 /* Pause data transmission */ -#define RESUMETX 0xe4 /* Resume data transmission */ -#define SMINT 0xe5 /* Set Modem Interrupt */ -#define SAFLOWC 0xe6 /* Set Aux. flow control chars */ -#define SBREAK 0xe8 /* Send break */ -#define SMODEM 0xe9 /* Set 8530 modem control lines */ -#define SIFLAG 0xea /* Set UNIX iflags */ -#define SFLOWC 0xeb /* Set flow control characters */ -#define STLOW 0xec /* Set transmit low water mark */ -#define RPAUSE 0xee /* Pause receive */ -#define RRESUME 0xef /* Resume receive */ -#define CHRESET 0xf0 /* Reset Channel */ -#define BUFSETALL 0xf2 /* Set Tx & Rx buffer size avail*/ -#define SOFLAG 0xf3 /* Set UNIX oflags */ -#define SHFLOW 0xf4 /* Set hardware handshake */ -#define SCFLAG 0xf5 /* Set UNIX cflags */ -#define SVNEXT 0xf6 /* Set VNEXT character */ -#define SPINTFC 0xfc /* Reserved */ -#define SCOMMODE 0xfd /* Set RS232/422 mode */ - - -/************************************************************************ - * Modes for SCOMMODE - ************************************************************************/ -#define MODE_232 0x00 -#define MODE_422 0x01 - - -/************************************************************************ - * Event flags. - ************************************************************************/ -#define IFBREAK 0x01 /* Break received */ -#define IFTLW 0x02 /* Transmit low water */ -#define IFTEM 0x04 /* Transmitter empty */ -#define IFDATA 0x08 /* Receive data present */ -#define IFMODEM 0x20 /* Modem status change */ - -/************************************************************************ - * Modem flags - ************************************************************************/ -# define DM_RTS 0x02 /* Request to send */ -# define DM_CD 0x80 /* Carrier detect */ -# define DM_DSR 0x20 /* Data set ready */ -# define DM_CTS 0x10 /* Clear to send */ -# define DM_RI 0x40 /* Ring indicator */ -# define DM_DTR 0x01 /* Data terminal ready */ - - -#endif From 2d9adf208b60cf9362edfeff46620e4f3d29d6ca Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:07 -0500 Subject: [PATCH 0443/1375] staging: dgap: Merge dgap_pci.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_driver.h | 67 ++++++++++++++++++++++ drivers/staging/dgap/dgap_pci.h | 91 ------------------------------ 3 files changed, 67 insertions(+), 92 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_pci.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index bba9fac50d26..0dc8dd0e7efe 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -50,7 +50,6 @@ #include #include "dgap_driver.h" -#include "dgap_pci.h" #include "dgap_conf.h" #include "dgap_parse.h" #include "dgap_types.h" diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 8bd6416f274c..2187fde0a934 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -64,6 +64,73 @@ #define TRC_TO_CONSOLE 1 +/* + * defines from dgap_pci.h + */ +#define PCIMAX 32 /* maximum number of PCI boards */ + +#define DIGI_VID 0x114F + +#define PCI_DEVICE_EPC_DID 0x0002 +#define PCI_DEVICE_XEM_DID 0x0004 +#define PCI_DEVICE_XR_DID 0x0005 +#define PCI_DEVICE_CX_DID 0x0006 +#define PCI_DEVICE_XRJ_DID 0x0009 /* PLX-based Xr adapter */ +#define PCI_DEVICE_XR_IBM_DID 0x0011 /* IBM 8-port Async Adapter */ +#define PCI_DEVICE_XR_BULL_DID 0x0013 /* BULL 8-port Async Adapter */ +#define PCI_DEVICE_XR_SAIP_DID 0x001c /* SAIP card - Xr adapter */ +#define PCI_DEVICE_XR_422_DID 0x0012 /* Xr-422 */ +#define PCI_DEVICE_920_2_DID 0x0034 /* XR-Plus 920 K, 2 port */ +#define PCI_DEVICE_920_4_DID 0x0026 /* XR-Plus 920 K, 4 port */ +#define PCI_DEVICE_920_8_DID 0x0027 /* XR-Plus 920 K, 8 port */ +#define PCI_DEVICE_EPCJ_DID 0x000a /* PLX 9060 chip for PCI */ +#define PCI_DEVICE_CX_IBM_DID 0x001b /* IBM 128-port Async Adapter */ +#define PCI_DEVICE_920_8_HP_DID 0x0058 /* HP XR-Plus 920 K, 8 port */ +#define PCI_DEVICE_XEM_HP_DID 0x0059 /* HP Xem PCI */ + +#define PCI_DEVICE_XEM_NAME "AccelePort XEM" +#define PCI_DEVICE_CX_NAME "AccelePort CX" +#define PCI_DEVICE_XR_NAME "AccelePort Xr" +#define PCI_DEVICE_XRJ_NAME "AccelePort Xr (PLX)" +#define PCI_DEVICE_XR_SAIP_NAME "AccelePort Xr (SAIP)" +#define PCI_DEVICE_920_2_NAME "AccelePort Xr920 2 port" +#define PCI_DEVICE_920_4_NAME "AccelePort Xr920 4 port" +#define PCI_DEVICE_920_8_NAME "AccelePort Xr920 8 port" +#define PCI_DEVICE_XR_422_NAME "AccelePort Xr 422" +#define PCI_DEVICE_EPCJ_NAME "AccelePort EPC (PLX)" +#define PCI_DEVICE_XR_BULL_NAME "AccelePort Xr (BULL)" +#define PCI_DEVICE_XR_IBM_NAME "AccelePort Xr (IBM)" +#define PCI_DEVICE_CX_IBM_NAME "AccelePort CX (IBM)" +#define PCI_DEVICE_920_8_HP_NAME "AccelePort Xr920 8 port (HP)" +#define PCI_DEVICE_XEM_HP_NAME "AccelePort XEM (HP)" + +/* + * On the PCI boards, there is no IO space allocated + * The I/O registers will be in the first 3 bytes of the + * upper 2MB of the 4MB memory space. The board memory + * will be mapped into the low 2MB of the 4MB memory space + */ + +/* Potential location of PCI Bios from E0000 to FFFFF*/ +#define PCI_BIOS_SIZE 0x00020000 + +/* Size of Memory and I/O for PCI (4MB) */ +#define PCI_RAM_SIZE 0x00400000 + +/* Size of Memory (2MB) */ +#define PCI_MEM_SIZE 0x00200000 + +/* Max PCI Window Size (2MB) */ +#define PCI_WIN_SIZE 0x00200000 + +#define PCI_WIN_SHIFT 21 /* 21 bits max */ + +/* Offset of I/0 in Memory (2MB) */ +#define PCI_IO_OFFSET 0x00200000 + +/* Size of IO (2MB) */ +#define PCI_IO_SIZE 0x00200000 + /* * Debugging levels can be set using debug insmod variable * They can also be compiled out completely. diff --git a/drivers/staging/dgap/dgap_pci.h b/drivers/staging/dgap/dgap_pci.h deleted file mode 100644 index bd498440a9b9..000000000000 --- a/drivers/staging/dgap/dgap_pci.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - - -#ifndef __DGAP_PCI_H -#define __DGAP_PCI_H - -#define PCIMAX 32 /* maximum number of PCI boards */ - -#define DIGI_VID 0x114F - -#define PCI_DEVICE_EPC_DID 0x0002 -#define PCI_DEVICE_XEM_DID 0x0004 -#define PCI_DEVICE_XR_DID 0x0005 -#define PCI_DEVICE_CX_DID 0x0006 -#define PCI_DEVICE_XRJ_DID 0x0009 /* PLX-based Xr adapter */ -#define PCI_DEVICE_XR_IBM_DID 0x0011 /* IBM 8-port Async Adapter */ -#define PCI_DEVICE_XR_BULL_DID 0x0013 /* BULL 8-port Async Adapter */ -#define PCI_DEVICE_XR_SAIP_DID 0x001c /* SAIP card - Xr adapter */ -#define PCI_DEVICE_XR_422_DID 0x0012 /* Xr-422 */ -#define PCI_DEVICE_920_2_DID 0x0034 /* XR-Plus 920 K, 2 port */ -#define PCI_DEVICE_920_4_DID 0x0026 /* XR-Plus 920 K, 4 port */ -#define PCI_DEVICE_920_8_DID 0x0027 /* XR-Plus 920 K, 8 port */ -#define PCI_DEVICE_EPCJ_DID 0x000a /* PLX 9060 chip for PCI */ -#define PCI_DEVICE_CX_IBM_DID 0x001b /* IBM 128-port Async Adapter */ -#define PCI_DEVICE_920_8_HP_DID 0x0058 /* HP XR-Plus 920 K, 8 port */ -#define PCI_DEVICE_XEM_HP_DID 0x0059 /* HP Xem PCI */ - -#define PCI_DEVICE_XEM_NAME "AccelePort XEM" -#define PCI_DEVICE_CX_NAME "AccelePort CX" -#define PCI_DEVICE_XR_NAME "AccelePort Xr" -#define PCI_DEVICE_XRJ_NAME "AccelePort Xr (PLX)" -#define PCI_DEVICE_XR_SAIP_NAME "AccelePort Xr (SAIP)" -#define PCI_DEVICE_920_2_NAME "AccelePort Xr920 2 port" -#define PCI_DEVICE_920_4_NAME "AccelePort Xr920 4 port" -#define PCI_DEVICE_920_8_NAME "AccelePort Xr920 8 port" -#define PCI_DEVICE_XR_422_NAME "AccelePort Xr 422" -#define PCI_DEVICE_EPCJ_NAME "AccelePort EPC (PLX)" -#define PCI_DEVICE_XR_BULL_NAME "AccelePort Xr (BULL)" -#define PCI_DEVICE_XR_IBM_NAME "AccelePort Xr (IBM)" -#define PCI_DEVICE_CX_IBM_NAME "AccelePort CX (IBM)" -#define PCI_DEVICE_920_8_HP_NAME "AccelePort Xr920 8 port (HP)" -#define PCI_DEVICE_XEM_HP_NAME "AccelePort XEM (HP)" - - -/* - * On the PCI boards, there is no IO space allocated - * The I/O registers will be in the first 3 bytes of the - * upper 2MB of the 4MB memory space. The board memory - * will be mapped into the low 2MB of the 4MB memory space - */ - -/* Potential location of PCI Bios from E0000 to FFFFF*/ -#define PCI_BIOS_SIZE 0x00020000 - -/* Size of Memory and I/O for PCI (4MB) */ -#define PCI_RAM_SIZE 0x00400000 - -/* Size of Memory (2MB) */ -#define PCI_MEM_SIZE 0x00200000 - -/* Max PCI Window Size (2MB) */ -#define PCI_WIN_SIZE 0x00200000 - -#define PCI_WIN_SHIFT 21 /* 21 bits max */ - -/* Offset of I/0 in Memory (2MB) */ -#define PCI_IO_OFFSET 0x00200000 - -/* Size of IO (2MB) */ -#define PCI_IO_SIZE 0x00200000 - -#endif From e49a00bceb363e5d3b3c440c9203ffd74727b214 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:08 -0500 Subject: [PATCH 0444/1375] staging: dgap: Merge dgap_conf.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_conf.h | 289 ----------------------------- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_driver.h | 261 ++++++++++++++++++++++++++ 3 files changed, 261 insertions(+), 290 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_conf.h diff --git a/drivers/staging/dgap/dgap_conf.h b/drivers/staging/dgap/dgap_conf.h deleted file mode 100644 index 92d22ecc6f07..000000000000 --- a/drivers/staging/dgap/dgap_conf.h +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - ***************************************************************************** - * - * dgap_conf.h - Header file for installations and parse files. - * - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef _DGAP_CONF_H -#define _DGAP_CONF_H - -#define NULLNODE 0 /* header node, not used */ -#define BNODE 1 /* Board node */ -#define LNODE 2 /* Line node */ -#define CNODE 3 /* Concentrator node */ -#define MNODE 4 /* EBI Module node */ -#define TNODE 5 /* tty name prefix node */ -#define CUNODE 6 /* cu name prefix (non-SCO) */ -#define PNODE 7 /* trans. print prefix node */ -#define JNODE 8 /* maJor number node */ -#define ANODE 9 /* altpin */ -#define TSNODE 10 /* tty structure size */ -#define CSNODE 11 /* channel structure size */ -#define BSNODE 12 /* board structure size */ -#define USNODE 13 /* unit schedule structure size */ -#define FSNODE 14 /* f2200 structure size */ -#define VSNODE 15 /* size of VPIX structures */ -#define INTRNODE 16 /* enable interrupt */ - -/* Enumeration of tokens */ -#define BEGIN 1 -#define END 2 -#define BOARD 10 - -#define EPCFS 11 /* start of EPC family definitions */ -#define ICX 11 -#define MCX 13 -#define PCX 14 -#define IEPC 15 -#define EEPC 16 -#define MEPC 17 -#define IPCM 18 -#define EPCM 19 -#define MPCM 20 -#define PEPC 21 -#define PPCM 22 -#ifdef CP -#define ICP 23 -#define ECP 24 -#define MCP 25 -#endif -#define EPCFE 25 /* end of EPC family definitions */ -#define PC2E 26 -#define PC4E 27 -#define PC4E8K 28 -#define PC8E 29 -#define PC8E8K 30 -#define PC16E 31 -#define MC2E8K 34 -#define MC4E8K 35 -#define MC8E8K 36 - -#define AVANFS 42 /* start of Avanstar family definitions */ -#define A8P 42 -#define A16P 43 -#define AVANFE 43 /* end of Avanstar family definitions */ - -#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ -#define DA22 44 /* AccelePort 2002 */ -#define DA24 45 /* AccelePort 2004 */ -#define DA28 46 /* AccelePort 2008 */ -#define DA216 47 /* AccelePort 2016 */ -#define DAR4 48 /* AccelePort RAS 4 port */ -#define DAR8 49 /* AccelePort RAS 8 port */ -#define DDR24 50 /* DataFire RAS 24 port */ -#define DDR30 51 /* DataFire RAS 30 port */ -#define DDR48 52 /* DataFire RAS 48 port */ -#define DDR60 53 /* DataFire RAS 60 port */ -#define DA2000FE 53 /* end of AccelePort 2000/RAS family definitions */ - -#define PCXRFS 106 /* start of PCXR family definitions */ -#define APORT4 106 -#define APORT8 107 -#define PAPORT4 108 -#define PAPORT8 109 -#define APORT4_920I 110 -#define APORT8_920I 111 -#define APORT4_920P 112 -#define APORT8_920P 113 -#define APORT2_920P 114 -#define PCXRFE 117 /* end of PCXR family definitions */ - -#define LINE 82 -#ifdef T1 -#define T1M 83 -#define E1M 84 -#endif -#define CONC 64 -#define CX 65 -#define EPC 66 -#define MOD 67 -#define PORTS 68 -#define METHOD 69 -#define CUSTOM 70 -#define BASIC 71 -#define STATUS 72 -#define MODEM 73 -/* The following tokens can appear in multiple places */ -#define SPEED 74 -#define NPORTS 75 -#define ID 76 -#define CABLE 77 -#define CONNECT 78 -#define IO 79 -#define MEM 80 -#define DPSZ 81 - -#define TTYN 90 -#define CU 91 -#define PRINT 92 -#define XPRINT 93 -#define CMAJOR 94 -#define ALTPIN 95 -#define STARTO 96 -#define USEINTR 97 -#define PCIINFO 98 - -#define TTSIZ 100 -#define CHSIZ 101 -#define BSSIZ 102 -#define UNTSIZ 103 -#define F2SIZ 104 -#define VPSIZ 105 - -#define TOTAL_BOARD 2 -#define CURRENT_BRD 4 -#define BOARD_TYPE 6 -#define IO_ADDRESS 8 -#define MEM_ADDRESS 10 - -#define FIELDS_PER_PAGE 18 - -#define TB_FIELD 1 -#define CB_FIELD 3 -#define BT_FIELD 5 -#define IO_FIELD 7 -#define ID_FIELD 8 -#define ME_FIELD 9 -#define TTY_FIELD 11 -#define CU_FIELD 13 -#define PR_FIELD 15 -#define MPR_FIELD 17 - -#define MAX_FIELD 512 - -#define INIT 0 -#define NITEMS 128 -#define MAX_ITEM 512 - -#define DSCRINST 1 -#define DSCRNUM 3 -#define ALTPINQ 5 -#define SSAVE 7 - -#define DSCR "32" -#define ONETONINE "123456789" -#define ALL "1234567890" - - -struct cnode { - struct cnode *next; - int type; - int numbrd; - - union { - struct { - char type; /* Board Type */ - short port; /* I/O Address */ - char *portstr; /* I/O Address in string */ - long addr; /* Memory Address */ - char *addrstr; /* Memory Address in string */ - long pcibus; /* PCI BUS */ - char *pcibusstr; /* PCI BUS in string */ - long pcislot; /* PCI SLOT */ - char *pcislotstr; /* PCI SLOT in string */ - char nport; /* Number of Ports */ - char *id; /* tty id */ - int start; /* start of tty counting */ - char *method; /* Install method */ - char v_type; - char v_port; - char v_addr; - char v_pcibus; - char v_pcislot; - char v_nport; - char v_id; - char v_start; - char v_method; - char line1; - char line2; - char conc1; /* total concs in line1 */ - char conc2; /* total concs in line2 */ - char module1; /* total modules for line1 */ - char module2; /* total modules for line2 */ - char *status; /* config status */ - char *dimstatus; /* Y/N */ - int status_index; /* field pointer */ - } board; - - struct { - char *cable; - char v_cable; - char speed; - char v_speed; - } line; - - struct { - char type; - char *connect; - char speed; - char nport; - char *id; - char *idstr; - int start; - char v_type; - char v_connect; - char v_speed; - char v_nport; - char v_id; - char v_start; - } conc; - - struct { - char type; - char nport; - char *id; - char *idstr; - int start; - char v_type; - char v_nport; - char v_id; - char v_start; - } module; - - char *ttyname; - - char *cuname; - - char *printname; - - int majornumber; - - int altpin; - - int ttysize; - - int chsize; - - int bssize; - - int unsize; - - int f2size; - - int vpixsize; - - int useintr; - } u; -}; - -#endif diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 0dc8dd0e7efe..fea2490a4d6a 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -50,7 +50,6 @@ #include #include "dgap_driver.h" -#include "dgap_conf.h" #include "dgap_parse.h" #include "dgap_types.h" diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 2187fde0a934..ce78212783b1 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -418,6 +418,166 @@ # define DM_RI 0x40 /* Ring indicator */ # define DM_DTR 0x01 /* Data terminal ready */ +/* + * defines from dgap_conf.h + */ +#define NULLNODE 0 /* header node, not used */ +#define BNODE 1 /* Board node */ +#define LNODE 2 /* Line node */ +#define CNODE 3 /* Concentrator node */ +#define MNODE 4 /* EBI Module node */ +#define TNODE 5 /* tty name prefix node */ +#define CUNODE 6 /* cu name prefix (non-SCO) */ +#define PNODE 7 /* trans. print prefix node */ +#define JNODE 8 /* maJor number node */ +#define ANODE 9 /* altpin */ +#define TSNODE 10 /* tty structure size */ +#define CSNODE 11 /* channel structure size */ +#define BSNODE 12 /* board structure size */ +#define USNODE 13 /* unit schedule structure size */ +#define FSNODE 14 /* f2200 structure size */ +#define VSNODE 15 /* size of VPIX structures */ +#define INTRNODE 16 /* enable interrupt */ + +/* Enumeration of tokens */ +#define BEGIN 1 +#define END 2 +#define BOARD 10 + +#define EPCFS 11 /* start of EPC family definitions */ +#define ICX 11 +#define MCX 13 +#define PCX 14 +#define IEPC 15 +#define EEPC 16 +#define MEPC 17 +#define IPCM 18 +#define EPCM 19 +#define MPCM 20 +#define PEPC 21 +#define PPCM 22 +#ifdef CP +#define ICP 23 +#define ECP 24 +#define MCP 25 +#endif +#define EPCFE 25 /* end of EPC family definitions */ +#define PC2E 26 +#define PC4E 27 +#define PC4E8K 28 +#define PC8E 29 +#define PC8E8K 30 +#define PC16E 31 +#define MC2E8K 34 +#define MC4E8K 35 +#define MC8E8K 36 + +#define AVANFS 42 /* start of Avanstar family definitions */ +#define A8P 42 +#define A16P 43 +#define AVANFE 43 /* end of Avanstar family definitions */ + +#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ +#define DA22 44 /* AccelePort 2002 */ +#define DA24 45 /* AccelePort 2004 */ +#define DA28 46 /* AccelePort 2008 */ +#define DA216 47 /* AccelePort 2016 */ +#define DAR4 48 /* AccelePort RAS 4 port */ +#define DAR8 49 /* AccelePort RAS 8 port */ +#define DDR24 50 /* DataFire RAS 24 port */ +#define DDR30 51 /* DataFire RAS 30 port */ +#define DDR48 52 /* DataFire RAS 48 port */ +#define DDR60 53 /* DataFire RAS 60 port */ +#define DA2000FE 53 /* end of AccelePort 2000/RAS family definitions */ + +#define PCXRFS 106 /* start of PCXR family definitions */ +#define APORT4 106 +#define APORT8 107 +#define PAPORT4 108 +#define PAPORT8 109 +#define APORT4_920I 110 +#define APORT8_920I 111 +#define APORT4_920P 112 +#define APORT8_920P 113 +#define APORT2_920P 114 +#define PCXRFE 117 /* end of PCXR family definitions */ + +#define LINE 82 +#ifdef T1 +#define T1M 83 +#define E1M 84 +#endif +#define CONC 64 +#define CX 65 +#define EPC 66 +#define MOD 67 +#define PORTS 68 +#define METHOD 69 +#define CUSTOM 70 +#define BASIC 71 +#define STATUS 72 +#define MODEM 73 +/* The following tokens can appear in multiple places */ +#define SPEED 74 +#define NPORTS 75 +#define ID 76 +#define CABLE 77 +#define CONNECT 78 +#define IO 79 +#define MEM 80 +#define DPSZ 81 + +#define TTYN 90 +#define CU 91 +#define PRINT 92 +#define XPRINT 93 +#define CMAJOR 94 +#define ALTPIN 95 +#define STARTO 96 +#define USEINTR 97 +#define PCIINFO 98 + +#define TTSIZ 100 +#define CHSIZ 101 +#define BSSIZ 102 +#define UNTSIZ 103 +#define F2SIZ 104 +#define VPSIZ 105 + +#define TOTAL_BOARD 2 +#define CURRENT_BRD 4 +#define BOARD_TYPE 6 +#define IO_ADDRESS 8 +#define MEM_ADDRESS 10 + +#define FIELDS_PER_PAGE 18 + +#define TB_FIELD 1 +#define CB_FIELD 3 +#define BT_FIELD 5 +#define IO_FIELD 7 +#define ID_FIELD 8 +#define ME_FIELD 9 +#define TTY_FIELD 11 +#define CU_FIELD 13 +#define PR_FIELD 15 +#define MPR_FIELD 17 + +#define MAX_FIELD 512 + +#define INIT 0 +#define NITEMS 128 +#define MAX_ITEM 512 + +#define DSCRINST 1 +#define DSCRNUM 3 +#define ALTPINQ 5 +#define SSAVE 7 + +#define DSCR "32" +#define ONETONINE "123456789" +#define ALL "1234567890" + /* * All the possible states the driver can be while being loaded. */ @@ -854,6 +1014,107 @@ struct bs_t { volatile unsigned char scc[16]; /* U SCC registers */ }; +struct cnode { + struct cnode *next; + int type; + int numbrd; + + union { + struct { + char type; /* Board Type */ + short port; /* I/O Address */ + char *portstr; /* I/O Address in string */ + long addr; /* Memory Address */ + char *addrstr; /* Memory Address in string */ + long pcibus; /* PCI BUS */ + char *pcibusstr; /* PCI BUS in string */ + long pcislot; /* PCI SLOT */ + char *pcislotstr; /* PCI SLOT in string */ + char nport; /* Number of Ports */ + char *id; /* tty id */ + int start; /* start of tty counting */ + char *method; /* Install method */ + char v_type; + char v_port; + char v_addr; + char v_pcibus; + char v_pcislot; + char v_nport; + char v_id; + char v_start; + char v_method; + char line1; + char line2; + char conc1; /* total concs in line1 */ + char conc2; /* total concs in line2 */ + char module1; /* total modules for line1 */ + char module2; /* total modules for line2 */ + char *status; /* config status */ + char *dimstatus; /* Y/N */ + int status_index; /* field pointer */ + } board; + + struct { + char *cable; + char v_cable; + char speed; + char v_speed; + } line; + + struct { + char type; + char *connect; + char speed; + char nport; + char *id; + char *idstr; + int start; + char v_type; + char v_connect; + char v_speed; + char v_nport; + char v_id; + char v_start; + } conc; + + struct { + char type; + char nport; + char *id; + char *idstr; + int start; + char v_type; + char v_nport; + char v_id; + char v_start; + } module; + + char *ttyname; + + char *cuname; + + char *printname; + + int majornumber; + + int altpin; + + int ttysize; + + int chsize; + + int bssize; + + int unsize; + + int f2size; + + int vpixsize; + + int useintr; + } u; +}; + /************************************************************************* * * Prototypes for non-static functions used in more than one module From 9e9b3bb7698ca9d0a35c69de8ad427143c6490e7 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:09 -0500 Subject: [PATCH 0445/1375] staging: dgap: Merge dgap_parse.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 12 +++++++++- drivers/staging/dgap/dgap_parse.h | 35 ------------------------------ 2 files changed, 11 insertions(+), 36 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_parse.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index fea2490a4d6a..8436ae339c0c 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -50,7 +50,6 @@ #include #include "dgap_driver.h" -#include "dgap_parse.h" #include "dgap_types.h" #define init_MUTEX(sem) sema_init(sem, 1) @@ -169,6 +168,17 @@ int dgap_tty_class_destroy(void); void dgap_create_tty_sysfs(struct un_t *un, struct device *c); void dgap_remove_tty_sysfs(struct device *c); +/* + * Function prototypes from dgap_parse.h + */ +int dgap_parsefile(char **in, int Remove); +struct cnode *dgap_find_config(int type, int bus, int slot); +uint dgap_config_get_number_of_ports(struct board_t *bd); +char *dgap_create_config_string(struct board_t *bd, char *string); +char *dgap_get_config_letters(struct board_t *bd, char *string); +uint dgap_config_get_useintr(struct board_t *bd); +uint dgap_config_get_altpin(struct board_t *bd); + /* Driver load/unload functions */ int dgap_init_module(void); void dgap_cleanup_module(void); diff --git a/drivers/staging/dgap/dgap_parse.h b/drivers/staging/dgap/dgap_parse.h deleted file mode 100644 index 8128c47343cb..000000000000 --- a/drivers/staging/dgap/dgap_parse.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef _DGAP_PARSE_H -#define _DGAP_PARSE_H - -#include "dgap_driver.h" - -extern int dgap_parsefile(char **in, int Remove); -extern struct cnode *dgap_find_config(int type, int bus, int slot); -extern uint dgap_config_get_number_of_ports(struct board_t *bd); -extern char *dgap_create_config_string(struct board_t *bd, char *string); -extern char *dgap_get_config_letters(struct board_t *bd, char *string); -extern uint dgap_config_get_useintr(struct board_t *bd); -extern uint dgap_config_get_altpin(struct board_t *bd); - -#endif From 81d5fb3c5902497571df054e30935c090b78e964 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:10 -0500 Subject: [PATCH 0446/1375] staging: dgap: Merge dgap_kcompat.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.h | 33 ++++++++++++++- drivers/staging/dgap/dgap_kcompat.h | 64 ----------------------------- 2 files changed, 32 insertions(+), 65 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_kcompat.h diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index ce78212783b1..6bef52dceeb2 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -33,7 +33,38 @@ #include "dgap_types.h" /* Additional types needed by the Digi header files */ #include "digi.h" /* Digi specific ioctl header */ -#include "dgap_kcompat.h" /* Kernel 2.4/2.6 compat includes */ + +#if !defined(TTY_FLIPBUF_SIZE) +# define TTY_FLIPBUF_SIZE 512 +#endif + +/* Sparse stuff */ +# ifndef __user +# define __user +# define __kernel +# define __safe +# define __force +# define __chk_user_ptr(x) (void)0 +# endif + + +# define PARM_STR(VAR, INIT, PERM, DESC) \ + static char *VAR = INIT; \ + char *dgap_##VAR; \ + module_param(VAR, charp, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + +# define PARM_INT(VAR, INIT, PERM, DESC) \ + static int VAR = INIT; \ + int dgap_##VAR; \ + module_param(VAR, int, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + +# define PARM_ULONG(VAR, INIT, PERM, DESC) \ + static ulong VAR = INIT; \ + ulong dgap_##VAR; \ + module_param(VAR, long, PERM); \ + MODULE_PARM_DESC(VAR, DESC); /************************************************************************* * diff --git a/drivers/staging/dgap/dgap_kcompat.h b/drivers/staging/dgap/dgap_kcompat.h deleted file mode 100644 index 0dc2404922ff..000000000000 --- a/drivers/staging/dgap/dgap_kcompat.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2004 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - * - ************************************************************************* - * - * This file is intended to contain all the kernel "differences" between the - * various kernels that we support. - * - *************************************************************************/ - -#ifndef __DGAP_KCOMPAT_H -#define __DGAP_KCOMPAT_H - -#if !defined(TTY_FLIPBUF_SIZE) -# define TTY_FLIPBUF_SIZE 512 -#endif - - -/* Sparse stuff */ -# ifndef __user -# define __user -# define __kernel -# define __safe -# define __force -# define __chk_user_ptr(x) (void)0 -# endif - - -# define PARM_STR(VAR, INIT, PERM, DESC) \ - static char *VAR = INIT; \ - char *dgap_##VAR; \ - module_param(VAR, charp, PERM); \ - MODULE_PARM_DESC(VAR, DESC); - -# define PARM_INT(VAR, INIT, PERM, DESC) \ - static int VAR = INIT; \ - int dgap_##VAR; \ - module_param(VAR, int, PERM); \ - MODULE_PARM_DESC(VAR, DESC); - -# define PARM_ULONG(VAR, INIT, PERM, DESC) \ - static ulong VAR = INIT; \ - ulong dgap_##VAR; \ - module_param(VAR, long, PERM); \ - MODULE_PARM_DESC(VAR, DESC); - -#endif /* ! __DGAP_KCOMPAT_H */ From 4c15e811b20a0e0954a10a84c12390db3b9b0b41 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:11 -0500 Subject: [PATCH 0447/1375] staging: dgap: Merge dgap_types.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_driver.h | 12 +++++++++- drivers/staging/dgap/dgap_types.h | 36 ------------------------------ 3 files changed, 11 insertions(+), 38 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_types.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 8436ae339c0c..3bf09ee182c0 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -50,7 +50,6 @@ #include #include "dgap_driver.h" -#include "dgap_types.h" #define init_MUTEX(sem) sema_init(sem, 1) #define DECLARE_MUTEX(name) \ diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index 6bef52dceeb2..dd7c7175e57a 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -31,9 +31,19 @@ #include /* To pick up the various tty structs/defines */ #include /* For irqreturn_t type */ -#include "dgap_types.h" /* Additional types needed by the Digi header files */ #include "digi.h" /* Digi specific ioctl header */ +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + +/* Required for our shared headers! */ +typedef unsigned char uchar; + #if !defined(TTY_FLIPBUF_SIZE) # define TTY_FLIPBUF_SIZE 512 #endif diff --git a/drivers/staging/dgap/dgap_types.h b/drivers/staging/dgap/dgap_types.h deleted file mode 100644 index eca38c7f359d..000000000000 --- a/drivers/staging/dgap/dgap_types.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef __DGAP_TYPES_H -#define __DGAP_TYPES_H - -#ifndef TRUE -# define TRUE 1 -#endif - -#ifndef FALSE -# define FALSE 0 -#endif - -/* Required for our shared headers! */ -typedef unsigned char uchar; - -#endif From 31f2a1b67cb851422f230df28cc7570da3a2209c Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:12 -0500 Subject: [PATCH 0448/1375] staging: dgap: Merge digi.h into dgap_driver.h There is a lot of cleanup work to do on these digi drivers and merging as much as is possible will make it easier. I also notice that many merged drivers are single source and header. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.h | 353 ++++++++++++++++++++++++++- drivers/staging/dgap/digi.h | 375 ----------------------------- 2 files changed, 350 insertions(+), 378 deletions(-) delete mode 100644 drivers/staging/dgap/digi.h diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index dd7c7175e57a..ce6a9e808ddf 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -31,8 +31,6 @@ #include /* To pick up the various tty structs/defines */ #include /* For irqreturn_t type */ -#include "digi.h" /* Digi specific ioctl header */ - #ifndef TRUE # define TRUE 1 #endif @@ -859,6 +857,355 @@ struct un_t { #define SNIFF_WAIT_SPACE 0x4 +/************************************************************************ + *** Definitions for Digi ditty(1) command. + ************************************************************************/ + + +/* + * Copyright (c) 1988-96 Digi International Inc., All Rights Reserved. + */ + +/************************************************************************ + * This module provides application access to special Digi + * serial line enhancements which are not standard UNIX(tm) features. + ************************************************************************/ + +#if !defined(TIOCMODG) + +#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ +#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ + +#ifndef TIOCM_LE +#define TIOCM_LE 0x01 /* line enable */ +#define TIOCM_DTR 0x02 /* data terminal ready */ +#define TIOCM_RTS 0x04 /* request to send */ +#define TIOCM_ST 0x08 /* secondary transmit */ +#define TIOCM_SR 0x10 /* secondary receive */ +#define TIOCM_CTS 0x20 /* clear to send */ +#define TIOCM_CAR 0x40 /* carrier detect */ +#define TIOCM_RNG 0x80 /* ring indicator */ +#define TIOCM_DSR 0x100 /* data set ready */ +#define TIOCM_RI TIOCM_RNG /* ring (alternate) */ +#define TIOCM_CD TIOCM_CAR /* carrier detect (alt) */ +#endif + +#endif + +#if !defined(TIOCMSET) +#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ +#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ +#endif + +#if !defined(TIOCMBIC) +#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ +#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ +#endif + + +#if !defined(TIOCSDTR) +#define TIOCSDTR ('e'<<8) | 0 /* set DTR */ +#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ +#endif + +/************************************************************************ + * Ioctl command arguments for DIGI parameters. + ************************************************************************/ +#define DIGI_GETA ('e'<<8) | 94 /* Read params */ + +#define DIGI_SETA ('e'<<8) | 95 /* Set params */ +#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ +#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ + +#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */ + /* Adapter Memory */ + +#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ + /* control characters */ +#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ + /* control characters */ +#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ + /* flow control chars */ +#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ + /* flow control chars */ + +#define DIGI_GEDELAY ('d'<<8) | 246 /* Get edelay */ +#define DIGI_SEDELAY ('d'<<8) | 247 /* Set edelay */ + +struct digiflow_t { + unsigned char startc; /* flow cntl start char */ + unsigned char stopc; /* flow cntl stop char */ +}; + + +#ifdef FLOW_2200 +#define F2200_GETA ('e'<<8) | 104 /* Get 2x36 flow cntl flags */ +#define F2200_SETAW ('e'<<8) | 105 /* Set 2x36 flow cntl flags */ +#define F2200_MASK 0x03 /* 2200 flow cntl bit mask */ +#define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */ +#define PCNTL_2200 0x02 /* 2x36 printer flow cntl */ +#define F2200_XON 0xf8 +#define P2200_XON 0xf9 +#define F2200_XOFF 0xfa +#define P2200_XOFF 0xfb + +#define FXOFF_MASK 0x03 /* 2200 flow status mask */ +#define RCVD_FXOFF 0x01 /* 2x36 Terminal XOFF rcvd */ +#define RCVD_PXOFF 0x02 /* 2x36 Printer XOFF rcvd */ +#endif + +/************************************************************************ + * Values for digi_flags + ************************************************************************/ +#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ +#define DIGI_FAST 0x0002 /* Fast baud rates */ +#define RTSPACE 0x0004 /* RTS input flow control */ +#define CTSPACE 0x0008 /* CTS output flow control */ +#define DSRPACE 0x0010 /* DSR output flow control */ +#define DCDPACE 0x0020 /* DCD output flow control */ +#define DTRPACE 0x0040 /* DTR input flow control */ +#define DIGI_COOK 0x0080 /* Cooked processing done in FEP */ +#define DIGI_FORCEDCD 0x0100 /* Force carrier */ +#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */ +#define DIGI_AIXON 0x0400 /* Aux flow control in fep */ +#define DIGI_PRINTER 0x0800 /* Hold port open for flow cntrl*/ +#define DIGI_PP_INPUT 0x1000 /* Change parallel port to input*/ +#define DIGI_DTR_TOGGLE 0x2000 /* Support DTR Toggle */ +#define DIGI_422 0x4000 /* for 422/232 selectable panel */ +#define DIGI_RTS_TOGGLE 0x8000 /* Support RTS Toggle */ + +/************************************************************************ + * These options are not supported on the comxi. + ************************************************************************/ +#define DIGI_COMXI (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE) + +#define DIGI_PLEN 28 /* String length */ +#define DIGI_TSIZ 10 /* Terminal string len */ + +/************************************************************************ + * Structure used with ioctl commands for DIGI parameters. + ************************************************************************/ +struct digi_t { + unsigned short digi_flags; /* Flags (see above) */ + unsigned short digi_maxcps; /* Max printer CPS */ + unsigned short digi_maxchar; /* Max chars in print queue */ + unsigned short digi_bufsize; /* Buffer size */ + unsigned char digi_onlen; /* Length of ON string */ + unsigned char digi_offlen; /* Length of OFF string */ + char digi_onstr[DIGI_PLEN]; /* Printer on string */ + char digi_offstr[DIGI_PLEN]; /* Printer off string */ + char digi_term[DIGI_TSIZ]; /* terminal string */ +}; + +/************************************************************************ + * KME definitions and structures. + ************************************************************************/ +#define RW_IDLE 0 /* Operation complete */ +#define RW_READ 1 /* Read Concentrator Memory */ +#define RW_WRITE 2 /* Write Concentrator Memory */ + +struct rw_t { + unsigned char rw_req; /* Request type */ + unsigned char rw_board; /* Host Adapter board number */ + unsigned char rw_conc; /* Concentrator number */ + unsigned char rw_reserved; /* Reserved for expansion */ + unsigned long rw_addr; /* Address in concentrator */ + unsigned short rw_size; /* Read/write request length */ + unsigned char rw_data[128]; /* Data to read/write */ +}; + +/*********************************************************************** + * Shrink Buffer and Board Information definitions and structures. + + ************************************************************************/ + /* Board type return codes */ +#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */ +#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */ +#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */ +#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */ +#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ + + /* Non-Zero Result codes. */ +#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ +#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ +#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ +#define RESULT_TOOSML 4 /* Too small an area to shrink. */ +#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ + +struct shrink_buf_struct { + unsigned long shrink_buf_vaddr; /* Virtual address of board */ + unsigned long shrink_buf_phys; /* Physical address of board */ + unsigned long shrink_buf_bseg; /* Amount of board memory */ + unsigned long shrink_buf_hseg; /* '186 Beginning of Dual-Port */ + + unsigned long shrink_buf_lseg; /* '186 Beginning of freed memory */ + unsigned long shrink_buf_mseg; /* Linear address from start of + dual-port were freed memory + begins, host viewpoint. */ + + unsigned long shrink_buf_bdparam; /* Parameter for xxmemon and + xxmemoff */ + + unsigned long shrink_buf_reserva; /* Reserved */ + unsigned long shrink_buf_reservb; /* Reserved */ + unsigned long shrink_buf_reservc; /* Reserved */ + unsigned long shrink_buf_reservd; /* Reserved */ + + unsigned char shrink_buf_result; /* Reason for call failing + Zero is Good return */ + unsigned char shrink_buf_init; /* Non-Zero if it caused an + xxinit call. */ + + unsigned char shrink_buf_anports; /* Number of async ports */ + unsigned char shrink_buf_snports; /* Number of sync ports */ + unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, + 2 = PC/Xm, + 3 = PC/Xe + 4 = MC/Xi + 5 = COMX/i */ + unsigned char shrink_buf_card; /* Card number */ + +}; + +/************************************************************************ + * Structure to get driver status information + ************************************************************************/ +struct digi_dinfo { + unsigned long dinfo_nboards; /* # boards configured */ + char dinfo_reserved[12]; /* for future expansion */ + char dinfo_version[16]; /* driver version */ +}; + +#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ + +/************************************************************************ + * Structure used with ioctl commands for per-board information + * + * physsize and memsize differ when board has "windowed" memory + ************************************************************************/ +struct digi_info { + unsigned long info_bdnum; /* Board number (0 based) */ + unsigned long info_ioport; /* io port address */ + unsigned long info_physaddr; /* memory address */ + unsigned long info_physsize; /* Size of host mem window */ + unsigned long info_memsize; /* Amount of dual-port mem */ + /* on board */ + unsigned short info_bdtype; /* Board type */ + unsigned short info_nports; /* number of ports */ + char info_bdstate; /* board state */ + char info_reserved[7]; /* for future expansion */ +}; + +#define DIGI_GETBD ('d'<<8) | 249 /* get board info */ + +struct digi_stat { + unsigned int info_chan; /* Channel number (0 based) */ + unsigned int info_brd; /* Board number (0 based) */ + unsigned long info_cflag; /* cflag for channel */ + unsigned long info_iflag; /* iflag for channel */ + unsigned long info_oflag; /* oflag for channel */ + unsigned long info_mstat; /* mstat for channel */ + unsigned long info_tx_data; /* tx_data for channel */ + unsigned long info_rx_data; /* rx_data for channel */ + unsigned long info_hflow; /* hflow for channel */ + unsigned long info_reserved[8]; /* for future expansion */ +}; + +#define DIGI_GETSTAT ('d'<<8) | 244 /* get board info */ +/************************************************************************ + * + * Structure used with ioctl commands for per-channel information + * + ************************************************************************/ +struct digi_ch { + unsigned long info_bdnum; /* Board number (0 based) */ + unsigned long info_channel; /* Channel index number */ + unsigned long info_ch_cflag; /* Channel cflag */ + unsigned long info_ch_iflag; /* Channel iflag */ + unsigned long info_ch_oflag; /* Channel oflag */ + unsigned long info_chsize; /* Channel structure size */ + unsigned long info_sleep_stat; /* sleep status */ + dev_t info_dev; /* device number */ + unsigned char info_initstate; /* Channel init state */ + unsigned char info_running; /* Channel running state */ + long reserved[8]; /* reserved for future use */ +}; + +/* +* This structure is used with the DIGI_FEPCMD ioctl to +* tell the driver which port to send the command for. +*/ +struct digi_cmd { + int cmd; + int word; + int ncmds; + int chan; /* channel index (zero based) */ + int bdid; /* board index (zero based) */ +}; + +/* +* info_sleep_stat defines +*/ +#define INFO_RUNWAIT 0x0001 +#define INFO_WOPEN 0x0002 +#define INFO_TTIOW 0x0004 +#define INFO_CH_RWAIT 0x0008 +#define INFO_CH_WEMPTY 0x0010 +#define INFO_CH_WLOW 0x0020 +#define INFO_XXBUF_BUSY 0x0040 + +#define DIGI_GETCH ('d'<<8) | 245 /* get board info */ + +/* Board type definitions */ + +#define SUBTYPE 0007 +#define T_PCXI 0000 +#define T_PCXM 0001 +#define T_PCXE 0002 +#define T_PCXR 0003 +#define T_SP 0004 +#define T_SP_PLUS 0005 +# define T_HERC 0000 +# define T_HOU 0001 +# define T_LON 0002 +# define T_CHA 0003 +#define FAMILY 0070 +#define T_COMXI 0000 +#define T_PCXX 0010 +#define T_CX 0020 +#define T_EPC 0030 +#define T_PCLITE 0040 +#define T_SPXX 0050 +#define T_AVXX 0060 +#define T_DXB 0070 +#define T_A2K_4_8 0070 +#define BUSTYPE 0700 +#define T_ISABUS 0000 +#define T_MCBUS 0100 +#define T_EISABUS 0200 +#define T_PCIBUS 0400 + +/* Board State Definitions */ + +#define BD_RUNNING 0x0 +#define BD_REASON 0x7f +#define BD_NOTFOUND 0x1 +#define BD_NOIOPORT 0x2 +#define BD_NOMEM 0x3 +#define BD_NOBIOS 0x4 +#define BD_NOFEP 0x5 +#define BD_FAILED 0x6 +#define BD_ALLOCATED 0x7 +#define BD_TRIBOOT 0x8 +#define BD_BADKME 0x80 + +#define DIGI_LOOPBACK ('d'<<8) | 252 /* Enable/disable UART internal loopback */ +#define DIGI_SPOLL ('d'<<8) | 254 /* change poller rate */ + +#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ +#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ +#define DIGI_RESET_PORT ('e'<<8) | 93 /* Reset port */ + /************************************************************************ * Channel information structure. ************************************************************************/ @@ -1202,4 +1549,4 @@ extern void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned extern uint dgap_get_custom_baud(struct channel_t *ch); extern void dgap_firmware_reset_port(struct channel_t *ch); -#endif +#endif \ No newline at end of file diff --git a/drivers/staging/dgap/digi.h b/drivers/staging/dgap/digi.h deleted file mode 100644 index 4f490a40416a..000000000000 --- a/drivers/staging/dgap/digi.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef __DIGI_H -#define __DIGI_H - -/************************************************************************ - *** Definitions for Digi ditty(1) command. - ************************************************************************/ - - -/* - * Copyright (c) 1988-96 Digi International Inc., All Rights Reserved. - */ - -/************************************************************************ - * This module provides application access to special Digi - * serial line enhancements which are not standard UNIX(tm) features. - ************************************************************************/ - -#if !defined(TIOCMODG) - -#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ -#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ - -#ifndef TIOCM_LE -#define TIOCM_LE 0x01 /* line enable */ -#define TIOCM_DTR 0x02 /* data terminal ready */ -#define TIOCM_RTS 0x04 /* request to send */ -#define TIOCM_ST 0x08 /* secondary transmit */ -#define TIOCM_SR 0x10 /* secondary receive */ -#define TIOCM_CTS 0x20 /* clear to send */ -#define TIOCM_CAR 0x40 /* carrier detect */ -#define TIOCM_RNG 0x80 /* ring indicator */ -#define TIOCM_DSR 0x100 /* data set ready */ -#define TIOCM_RI TIOCM_RNG /* ring (alternate) */ -#define TIOCM_CD TIOCM_CAR /* carrier detect (alt) */ -#endif - -#endif - -#if !defined(TIOCMSET) -#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ -#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ -#endif - -#if !defined(TIOCMBIC) -#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ -#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ -#endif - - -#if !defined(TIOCSDTR) -#define TIOCSDTR ('e'<<8) | 0 /* set DTR */ -#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ -#endif - -/************************************************************************ - * Ioctl command arguments for DIGI parameters. - ************************************************************************/ -#define DIGI_GETA ('e'<<8) | 94 /* Read params */ - -#define DIGI_SETA ('e'<<8) | 95 /* Set params */ -#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ -#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ - -#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */ - /* Adapter Memory */ - -#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ - /* control characters */ -#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ - /* control characters */ -#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ - /* flow control chars */ -#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ - /* flow control chars */ - -#define DIGI_GEDELAY ('d'<<8) | 246 /* Get edelay */ -#define DIGI_SEDELAY ('d'<<8) | 247 /* Set edelay */ - -struct digiflow_t { - unsigned char startc; /* flow cntl start char */ - unsigned char stopc; /* flow cntl stop char */ -}; - - -#ifdef FLOW_2200 -#define F2200_GETA ('e'<<8) | 104 /* Get 2x36 flow cntl flags */ -#define F2200_SETAW ('e'<<8) | 105 /* Set 2x36 flow cntl flags */ -#define F2200_MASK 0x03 /* 2200 flow cntl bit mask */ -#define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */ -#define PCNTL_2200 0x02 /* 2x36 printer flow cntl */ -#define F2200_XON 0xf8 -#define P2200_XON 0xf9 -#define F2200_XOFF 0xfa -#define P2200_XOFF 0xfb - -#define FXOFF_MASK 0x03 /* 2200 flow status mask */ -#define RCVD_FXOFF 0x01 /* 2x36 Terminal XOFF rcvd */ -#define RCVD_PXOFF 0x02 /* 2x36 Printer XOFF rcvd */ -#endif - -/************************************************************************ - * Values for digi_flags - ************************************************************************/ -#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ -#define DIGI_FAST 0x0002 /* Fast baud rates */ -#define RTSPACE 0x0004 /* RTS input flow control */ -#define CTSPACE 0x0008 /* CTS output flow control */ -#define DSRPACE 0x0010 /* DSR output flow control */ -#define DCDPACE 0x0020 /* DCD output flow control */ -#define DTRPACE 0x0040 /* DTR input flow control */ -#define DIGI_COOK 0x0080 /* Cooked processing done in FEP */ -#define DIGI_FORCEDCD 0x0100 /* Force carrier */ -#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */ -#define DIGI_AIXON 0x0400 /* Aux flow control in fep */ -#define DIGI_PRINTER 0x0800 /* Hold port open for flow cntrl*/ -#define DIGI_PP_INPUT 0x1000 /* Change parallel port to input*/ -#define DIGI_DTR_TOGGLE 0x2000 /* Support DTR Toggle */ -#define DIGI_422 0x4000 /* for 422/232 selectable panel */ -#define DIGI_RTS_TOGGLE 0x8000 /* Support RTS Toggle */ - -/************************************************************************ - * These options are not supported on the comxi. - ************************************************************************/ -#define DIGI_COMXI (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE) - -#define DIGI_PLEN 28 /* String length */ -#define DIGI_TSIZ 10 /* Terminal string len */ - -/************************************************************************ - * Structure used with ioctl commands for DIGI parameters. - ************************************************************************/ -struct digi_t { - unsigned short digi_flags; /* Flags (see above) */ - unsigned short digi_maxcps; /* Max printer CPS */ - unsigned short digi_maxchar; /* Max chars in print queue */ - unsigned short digi_bufsize; /* Buffer size */ - unsigned char digi_onlen; /* Length of ON string */ - unsigned char digi_offlen; /* Length of OFF string */ - char digi_onstr[DIGI_PLEN]; /* Printer on string */ - char digi_offstr[DIGI_PLEN]; /* Printer off string */ - char digi_term[DIGI_TSIZ]; /* terminal string */ -}; - -/************************************************************************ - * KME definitions and structures. - ************************************************************************/ -#define RW_IDLE 0 /* Operation complete */ -#define RW_READ 1 /* Read Concentrator Memory */ -#define RW_WRITE 2 /* Write Concentrator Memory */ - -struct rw_t { - unsigned char rw_req; /* Request type */ - unsigned char rw_board; /* Host Adapter board number */ - unsigned char rw_conc; /* Concentrator number */ - unsigned char rw_reserved; /* Reserved for expansion */ - unsigned long rw_addr; /* Address in concentrator */ - unsigned short rw_size; /* Read/write request length */ - unsigned char rw_data[128]; /* Data to read/write */ -}; - -/*********************************************************************** - * Shrink Buffer and Board Information definitions and structures. - - ************************************************************************/ - /* Board type return codes */ -#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */ -#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */ -#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */ -#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */ -#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ - - /* Non-Zero Result codes. */ -#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ -#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ -#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ -#define RESULT_TOOSML 4 /* Too small an area to shrink. */ -#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ - -struct shrink_buf_struct { - unsigned long shrink_buf_vaddr; /* Virtual address of board */ - unsigned long shrink_buf_phys; /* Physical address of board */ - unsigned long shrink_buf_bseg; /* Amount of board memory */ - unsigned long shrink_buf_hseg; /* '186 Beginning of Dual-Port */ - - unsigned long shrink_buf_lseg; /* '186 Beginning of freed memory */ - unsigned long shrink_buf_mseg; /* Linear address from start of - dual-port were freed memory - begins, host viewpoint. */ - - unsigned long shrink_buf_bdparam; /* Parameter for xxmemon and - xxmemoff */ - - unsigned long shrink_buf_reserva; /* Reserved */ - unsigned long shrink_buf_reservb; /* Reserved */ - unsigned long shrink_buf_reservc; /* Reserved */ - unsigned long shrink_buf_reservd; /* Reserved */ - - unsigned char shrink_buf_result; /* Reason for call failing - Zero is Good return */ - unsigned char shrink_buf_init; /* Non-Zero if it caused an - xxinit call. */ - - unsigned char shrink_buf_anports; /* Number of async ports */ - unsigned char shrink_buf_snports; /* Number of sync ports */ - unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, - 2 = PC/Xm, - 3 = PC/Xe - 4 = MC/Xi - 5 = COMX/i */ - unsigned char shrink_buf_card; /* Card number */ - -}; - -/************************************************************************ - * Structure to get driver status information - ************************************************************************/ -struct digi_dinfo { - unsigned long dinfo_nboards; /* # boards configured */ - char dinfo_reserved[12]; /* for future expansion */ - char dinfo_version[16]; /* driver version */ -}; - -#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ - -/************************************************************************ - * Structure used with ioctl commands for per-board information - * - * physsize and memsize differ when board has "windowed" memory - ************************************************************************/ -struct digi_info { - unsigned long info_bdnum; /* Board number (0 based) */ - unsigned long info_ioport; /* io port address */ - unsigned long info_physaddr; /* memory address */ - unsigned long info_physsize; /* Size of host mem window */ - unsigned long info_memsize; /* Amount of dual-port mem */ - /* on board */ - unsigned short info_bdtype; /* Board type */ - unsigned short info_nports; /* number of ports */ - char info_bdstate; /* board state */ - char info_reserved[7]; /* for future expansion */ -}; - -#define DIGI_GETBD ('d'<<8) | 249 /* get board info */ - -struct digi_stat { - unsigned int info_chan; /* Channel number (0 based) */ - unsigned int info_brd; /* Board number (0 based) */ - unsigned long info_cflag; /* cflag for channel */ - unsigned long info_iflag; /* iflag for channel */ - unsigned long info_oflag; /* oflag for channel */ - unsigned long info_mstat; /* mstat for channel */ - unsigned long info_tx_data; /* tx_data for channel */ - unsigned long info_rx_data; /* rx_data for channel */ - unsigned long info_hflow; /* hflow for channel */ - unsigned long info_reserved[8]; /* for future expansion */ -}; - -#define DIGI_GETSTAT ('d'<<8) | 244 /* get board info */ -/************************************************************************ - * - * Structure used with ioctl commands for per-channel information - * - ************************************************************************/ -struct digi_ch { - unsigned long info_bdnum; /* Board number (0 based) */ - unsigned long info_channel; /* Channel index number */ - unsigned long info_ch_cflag; /* Channel cflag */ - unsigned long info_ch_iflag; /* Channel iflag */ - unsigned long info_ch_oflag; /* Channel oflag */ - unsigned long info_chsize; /* Channel structure size */ - unsigned long info_sleep_stat; /* sleep status */ - dev_t info_dev; /* device number */ - unsigned char info_initstate; /* Channel init state */ - unsigned char info_running; /* Channel running state */ - long reserved[8]; /* reserved for future use */ -}; - -/* -* This structure is used with the DIGI_FEPCMD ioctl to -* tell the driver which port to send the command for. -*/ -struct digi_cmd { - int cmd; - int word; - int ncmds; - int chan; /* channel index (zero based) */ - int bdid; /* board index (zero based) */ -}; - -/* -* info_sleep_stat defines -*/ -#define INFO_RUNWAIT 0x0001 -#define INFO_WOPEN 0x0002 -#define INFO_TTIOW 0x0004 -#define INFO_CH_RWAIT 0x0008 -#define INFO_CH_WEMPTY 0x0010 -#define INFO_CH_WLOW 0x0020 -#define INFO_XXBUF_BUSY 0x0040 - -#define DIGI_GETCH ('d'<<8) | 245 /* get board info */ - -/* Board type definitions */ - -#define SUBTYPE 0007 -#define T_PCXI 0000 -#define T_PCXM 0001 -#define T_PCXE 0002 -#define T_PCXR 0003 -#define T_SP 0004 -#define T_SP_PLUS 0005 -# define T_HERC 0000 -# define T_HOU 0001 -# define T_LON 0002 -# define T_CHA 0003 -#define FAMILY 0070 -#define T_COMXI 0000 -#define T_PCXX 0010 -#define T_CX 0020 -#define T_EPC 0030 -#define T_PCLITE 0040 -#define T_SPXX 0050 -#define T_AVXX 0060 -#define T_DXB 0070 -#define T_A2K_4_8 0070 -#define BUSTYPE 0700 -#define T_ISABUS 0000 -#define T_MCBUS 0100 -#define T_EISABUS 0200 -#define T_PCIBUS 0400 - -/* Board State Definitions */ - -#define BD_RUNNING 0x0 -#define BD_REASON 0x7f -#define BD_NOTFOUND 0x1 -#define BD_NOIOPORT 0x2 -#define BD_NOMEM 0x3 -#define BD_NOBIOS 0x4 -#define BD_NOFEP 0x5 -#define BD_FAILED 0x6 -#define BD_ALLOCATED 0x7 -#define BD_TRIBOOT 0x8 -#define BD_BADKME 0x80 - -#define DIGI_LOOPBACK ('d'<<8) | 252 /* Enable/disable UART internal loopback */ -#define DIGI_SPOLL ('d'<<8) | 254 /* change poller rate */ - -#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ -#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ -#define DIGI_RESET_PORT ('e'<<8) | 93 /* Reset port */ - -#endif /* DIGI_H */ From fe0ef8e66684893127741bdfdd909501e364d0d1 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:13 -0500 Subject: [PATCH 0449/1375] staging: dgap: Make merged and local functions and variables static This patch makes all merged and original functions static to dgap.c. Doing so has revealed more dead code via gcc warnings. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 159 ++++++++++++++++------------- drivers/staging/dgap/dgap_driver.h | 50 +-------- 2 files changed, 90 insertions(+), 119 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 3bf09ee182c0..21b0f90fbee8 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -122,13 +122,13 @@ static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c); static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); -int dgap_tty_register(struct board_t *brd); -int dgap_tty_preinit(void); -int dgap_tty_init(struct board_t *); -void dgap_tty_post_uninit(void); -void dgap_tty_uninit(struct board_t *); -void dgap_carrier(struct channel_t *ch); -void dgap_input(struct channel_t *ch); +static int dgap_tty_register(struct board_t *brd); +static int dgap_tty_preinit(void); +static int dgap_tty_init(struct board_t *); +static void dgap_tty_post_uninit(void); +static void dgap_tty_uninit(struct board_t *); +static void dgap_carrier(struct channel_t *ch); +static void dgap_input(struct channel_t *ch); /* * Our function prototypes from dgap_fep5 @@ -136,6 +136,15 @@ void dgap_input(struct channel_t *ch); static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); static int dgap_event(struct board_t *bd); +static void dgap_poll_tasklet(unsigned long data); +static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds); +static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds); +static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); +static int dgap_param(struct tty_struct *tty); +static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len); +static uint dgap_get_custom_baud(struct channel_t *ch); +static void dgap_firmware_reset_port(struct channel_t *ch); + /* * Function prototypes from dgap_parse.c. */ @@ -155,28 +164,38 @@ struct un_t; struct pci_driver; struct class_device; -void dgap_create_ports_sysfiles(struct board_t *bd); -void dgap_remove_ports_sysfiles(struct board_t *bd); +static void dgap_create_ports_sysfiles(struct board_t *bd); +static void dgap_remove_ports_sysfiles(struct board_t *bd); -void dgap_create_driver_sysfiles(struct pci_driver *); -void dgap_remove_driver_sysfiles(struct pci_driver *); +static void dgap_create_driver_sysfiles(struct pci_driver *); +static void dgap_remove_driver_sysfiles(struct pci_driver *); -int dgap_tty_class_init(void); -int dgap_tty_class_destroy(void); +static int dgap_tty_class_init(void); +static int dgap_tty_class_destroy(void); -void dgap_create_tty_sysfs(struct un_t *un, struct device *c); -void dgap_remove_tty_sysfs(struct device *c); +static void dgap_create_tty_sysfs(struct un_t *un, struct device *c); +static void dgap_remove_tty_sysfs(struct device *c); /* * Function prototypes from dgap_parse.h */ -int dgap_parsefile(char **in, int Remove); -struct cnode *dgap_find_config(int type, int bus, int slot); -uint dgap_config_get_number_of_ports(struct board_t *bd); -char *dgap_create_config_string(struct board_t *bd, char *string); -char *dgap_get_config_letters(struct board_t *bd, char *string); -uint dgap_config_get_useintr(struct board_t *bd); -uint dgap_config_get_altpin(struct board_t *bd); +static int dgap_parsefile(char **in, int Remove); +static struct cnode *dgap_find_config(int type, int bus, int slot); +static uint dgap_config_get_number_of_ports(struct board_t *bd); +static char *dgap_create_config_string(struct board_t *bd, char *string); +static char *dgap_get_config_letters(struct board_t *bd, char *string); +static uint dgap_config_get_useintr(struct board_t *bd); +static uint dgap_config_get_altpin(struct board_t *bd); + +static int dgap_ms_sleep(ulong ms); +static char *dgap_ioctl_name(int cmd); +static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); +static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len); +static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len); +static void dgap_do_config_load(uchar __user *uaddr, int len); +static int dgap_after_config_loaded(void); +static int dgap_finalize_board_init(struct board_t *brd); + /* Driver load/unload functions */ int dgap_init_module(void); @@ -198,16 +217,16 @@ static struct file_operations DgapBoardFops = /* * Globals */ -uint dgap_NumBoards; -struct board_t *dgap_Board[MAXBOARDS]; +static uint dgap_NumBoards; +static struct board_t *dgap_Board[MAXBOARDS]; DEFINE_SPINLOCK(dgap_global_lock); -ulong dgap_poll_counter; -char *dgap_config_buf; -int dgap_driver_state = DRIVER_INITIALIZED; +static ulong dgap_poll_counter; +static char *dgap_config_buf; +static int dgap_driver_state = DRIVER_INITIALIZED; DEFINE_SPINLOCK(dgap_dl_lock); -wait_queue_head_t dgap_dl_wait; -int dgap_dl_action; -int dgap_poll_tick = 20; /* Poll interval - 20 ms */ +static wait_queue_head_t dgap_dl_wait; +static int dgap_dl_action; +static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ /* * Static vars. @@ -219,13 +238,13 @@ static struct class * dgap_class; static struct board_t *dgap_BoardsByMajor[256]; static uchar *dgap_TmpWriteBuf = NULL; -static DECLARE_MUTEX(dgap_TmpWriteSem); +DECLARE_MUTEX(dgap_TmpWriteSem); static uint dgap_count = 500; /* * Poller stuff */ -static DEFINE_SPINLOCK(dgap_poll_lock); /* Poll scheduling lock */ +DEFINE_SPINLOCK(dgap_poll_lock); /* Poll scheduling lock */ static ulong dgap_poll_time; /* Time of next poll */ static uint dgap_poll_stop; /* Used to tell poller to stop */ static struct timer_list dgap_poll_timer; @@ -290,7 +309,7 @@ static struct pci_driver dgap_driver = { }; -char *dgap_state_text[] = { +static char *dgap_state_text[] = { "Board Failed", "Configuration for board not found.\n\t\t\tRun mpi to configure board.", "Board Found", @@ -314,7 +333,7 @@ char *dgap_state_text[] = { "Board READY", }; -char *dgap_driver_state_text[] = { +static char *dgap_driver_state_text[] = { "Driver Initialized", "Driver needs configuration load.", "Driver requested configuration from download daemon.", @@ -854,7 +873,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id) } -int dgap_finalize_board_init(struct board_t *brd) { +static int dgap_finalize_board_init(struct board_t *brd) { int rc; @@ -1186,7 +1205,7 @@ static void dgap_mbuf(struct board_t *brd, const char *fmt, ...) { * * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal. */ -int dgap_ms_sleep(ulong ms) +static int dgap_ms_sleep(ulong ms) { current->state = TASK_INTERRUPTIBLE; schedule_timeout((ms * HZ) / 1000); @@ -1198,7 +1217,7 @@ int dgap_ms_sleep(ulong ms) /* * dgap_ioctl_name() : Returns a text version of each ioctl value. */ -char *dgap_ioctl_name(int cmd) +static char *dgap_ioctl_name(int cmd) { switch(cmd) { @@ -1258,7 +1277,7 @@ char *dgap_ioctl_name(int cmd) * * Initialize any global tty related data before we download any boards. */ -int dgap_tty_preinit(void) +static int dgap_tty_preinit(void) { unsigned long flags; @@ -1288,7 +1307,7 @@ int dgap_tty_preinit(void) * * Init the tty subsystem for this board. */ -int dgap_tty_register(struct board_t *brd) +static int dgap_tty_register(struct board_t *brd) { int rc = 0; @@ -1384,7 +1403,7 @@ int dgap_tty_register(struct board_t *brd) * Init the tty subsystem. Called once per board after board has been * downloaded and init'ed. */ -int dgap_tty_init(struct board_t *brd) +static int dgap_tty_init(struct board_t *brd) { int i; int tlw; @@ -1562,7 +1581,7 @@ int dgap_tty_init(struct board_t *brd) * * UnInitialize any global tty related data. */ -void dgap_tty_post_uninit(void) +static void dgap_tty_post_uninit(void) { kfree(dgap_TmpWriteBuf); dgap_TmpWriteBuf = NULL; @@ -1575,7 +1594,7 @@ void dgap_tty_post_uninit(void) * Uninitialize the TTY portion of this driver. Free all memory and * resources. */ -void dgap_tty_uninit(struct board_t *brd) +static void dgap_tty_uninit(struct board_t *brd) { int i = 0; @@ -1733,7 +1752,7 @@ static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *b * *=======================================================================*/ -void dgap_input(struct channel_t *ch) +static void dgap_input(struct channel_t *ch) { struct board_t *bd; struct bs_t *bs; @@ -1950,7 +1969,7 @@ void dgap_input(struct channel_t *ch) * Determines when CARRIER changes state and takes appropriate * action. ************************************************************************/ -void dgap_carrier(struct channel_t *ch) +static void dgap_carrier(struct channel_t *ch) { struct board_t *bd; @@ -4640,7 +4659,7 @@ static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* * Loads the dgap.conf config file from the user. */ -void dgap_do_config_load(uchar __user *uaddr, int len) +static void dgap_do_config_load(uchar __user *uaddr, int len) { int orig_len = len; char *to_addr; @@ -4685,7 +4704,7 @@ void dgap_do_config_load(uchar __user *uaddr, int len) } -int dgap_after_config_loaded(void) +static int dgap_after_config_loaded(void) { int i = 0; int rc = 0; @@ -4750,7 +4769,7 @@ static int dgap_usertoboard(struct board_t *brd, char *to_addr, char __user *fro * Copies the BIOS code from the user to the board, * and starts the BIOS running. */ -void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len) +static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len) { uchar *addr; uint offset; @@ -4825,7 +4844,7 @@ static void dgap_do_wait_for_bios(struct board_t *brd) * Copies the FEP code from the user to the board, * and starts the FEP running. */ -void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) +static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) { uchar *addr; uint offset; @@ -4987,7 +5006,7 @@ failed: /* * Sends a concentrator image into the FEP5 board. */ -void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) +static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) { char *vaddr; u16 offset = 0; @@ -5122,7 +5141,7 @@ static void dgap_get_vpd(struct board_t *brd) /* * Our board poller function. */ -void dgap_poll_tasklet(unsigned long data) +static void dgap_poll_tasklet(unsigned long data) { struct board_t *bd = (struct board_t *) data; ulong lock_flags; @@ -5388,7 +5407,7 @@ out: * in the cmd buffer before returning. * *=======================================================================*/ -void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds) +static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds) { char *vaddr = NULL; struct cm_t *cm_addr = NULL; @@ -5478,7 +5497,7 @@ void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint n * in the cmd buffer before returning. * *=======================================================================*/ -void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) +static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) { char *vaddr = NULL; struct cm_t *cm_addr = NULL; @@ -5666,7 +5685,7 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) * cnt - Number of characters to move. * *=======================================================================*/ -void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) +static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) { int n; char *taddr; @@ -5721,7 +5740,7 @@ void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) * and returns it back to the user. * Returns 0 on error. */ -uint dgap_get_custom_baud(struct channel_t *ch) +static uint dgap_get_custom_baud(struct channel_t *ch) { uchar *vaddr; ulong offset = 0; @@ -5758,7 +5777,7 @@ uint dgap_get_custom_baud(struct channel_t *ch) /* * Calls the firmware to reset this channel. */ -void dgap_firmware_reset_port(struct channel_t *ch) +static void dgap_firmware_reset_port(struct channel_t *ch) { dgap_cmdb(ch, CHRESET, 0, 0, 0); @@ -5789,7 +5808,7 @@ void dgap_firmware_reset_port(struct channel_t *ch) * struct tty_struct * - TTY for port. * *=======================================================================*/ -int dgap_param(struct tty_struct *tty) +static int dgap_param(struct tty_struct *tty) { struct ktermios *ts; struct board_t *bd; @@ -6136,7 +6155,7 @@ int dgap_param(struct tty_struct *tty) * Convert the FEP5 way of reporting parity errors and breaks into * the Linux line discipline way. */ -void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len) +static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len) { int l = *len; int count = 0; @@ -6562,7 +6581,7 @@ static ssize_t dgap_driver_pollrate_store(struct device_driver *ddp, const char static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, dgap_driver_pollrate_store); -void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) +static void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) { int rc = 0; struct device_driver *driverfs = &dgap_driver->driver; @@ -6581,7 +6600,7 @@ void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) } -void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver) +static void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver) { struct device_driver *driverfs = &dgap_driver->driver; driver_remove_file(driverfs, &driver_attr_version); @@ -6791,7 +6810,7 @@ static DEVICE_ATTR(ports_txcount, S_IRUSR, dgap_ports_txcount_show, NULL); /* this function creates the sys files that will export each signal status * to sysfs each value will be put in a separate filename */ -void dgap_create_ports_sysfiles(struct board_t *bd) +static void dgap_create_ports_sysfiles(struct board_t *bd) { int rc = 0; @@ -6813,7 +6832,7 @@ void dgap_create_ports_sysfiles(struct board_t *bd) /* removes all the sys files created for that port */ -void dgap_remove_ports_sysfiles(struct board_t *bd) +static void dgap_remove_ports_sysfiles(struct board_t *bd) { device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); @@ -7212,7 +7231,7 @@ static struct attribute_group dgap_tty_attribute_group = { -void dgap_create_tty_sysfs(struct un_t *un, struct device *c) +static void dgap_create_tty_sysfs(struct un_t *un, struct device *c) { int ret; @@ -7228,7 +7247,7 @@ void dgap_create_tty_sysfs(struct un_t *un, struct device *c) } -void dgap_remove_tty_sysfs(struct device *c) +static void dgap_remove_tty_sysfs(struct device *c) { sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); } @@ -7236,7 +7255,7 @@ void dgap_remove_tty_sysfs(struct device *c) /* * Parse a configuration file read into memory as a string. */ -int dgap_parsefile(char **in, int Remove) +static int dgap_parsefile(char **in, int Remove) { struct cnode *p, *brd, *line, *conc; int rc; @@ -8212,7 +8231,7 @@ static char *dgap_savestring(char *s) /* * Given a board pointer, returns whether we should use interrupts or not. */ -uint dgap_config_get_useintr(struct board_t *bd) +static uint dgap_config_get_useintr(struct board_t *bd) { struct cnode *p = NULL; @@ -8239,7 +8258,7 @@ uint dgap_config_get_useintr(struct board_t *bd) /* * Given a board pointer, returns whether we turn on altpin or not. */ -uint dgap_config_get_altpin(struct board_t *bd) +static uint dgap_config_get_altpin(struct board_t *bd) { struct cnode *p = NULL; @@ -8268,7 +8287,7 @@ uint dgap_config_get_altpin(struct board_t *bd) * Given a specific type of board, if found, detached link and * returns the first occurrence in the list. */ -struct cnode *dgap_find_config(int type, int bus, int slot) +static struct cnode *dgap_find_config(int type, int bus, int slot) { struct cnode *p, *prev = NULL, *prev2 = NULL, *found = NULL; @@ -8334,7 +8353,7 @@ struct cnode *dgap_find_config(int type, int bus, int slot) * all ports user specified should be on the board. * (This does NOT mean they are all actually present right now tho) */ -uint dgap_config_get_number_of_ports(struct board_t *bd) +static uint dgap_config_get_number_of_ports(struct board_t *bd) { int count = 0; struct cnode *p = NULL; @@ -8363,7 +8382,7 @@ uint dgap_config_get_number_of_ports(struct board_t *bd) return (count); } -char *dgap_create_config_string(struct board_t *bd, char *string) +static char *dgap_create_config_string(struct board_t *bd, char *string) { char *ptr = string; struct cnode *p = NULL; @@ -8422,7 +8441,7 @@ char *dgap_create_config_string(struct board_t *bd, char *string) -char *dgap_get_config_letters(struct board_t *bd, char *string) +static char *dgap_get_config_letters(struct board_t *bd, char *string) { int found = FALSE; char *ptr = string; diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index ce6a9e808ddf..573aa18ee499 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -663,8 +663,6 @@ enum { REQUESTED_CONCENTRATOR }; -extern char *dgap_state_text[]; -extern char *dgap_driver_state_text[]; /* @@ -1503,50 +1501,4 @@ struct cnode { } u; }; -/************************************************************************* - * - * Prototypes for non-static functions used in more than one module - * - *************************************************************************/ - -extern int dgap_ms_sleep(ulong ms); -extern char *dgap_ioctl_name(int cmd); -extern void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); -extern void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len); -extern void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len); -extern void dgap_do_config_load(uchar __user *uaddr, int len); -extern int dgap_after_config_loaded(void); -extern int dgap_finalize_board_init(struct board_t *brd); - -/* - * Our Global Variables. - */ -extern int dgap_driver_state; /* The state of the driver */ -extern int dgap_debug; /* Debug variable */ -extern int dgap_rawreadok; /* Set if user wants rawreads */ -extern int dgap_poll_tick; /* Poll interval - 20 ms */ -extern spinlock_t dgap_global_lock; /* Driver global spinlock */ -extern uint dgap_NumBoards; /* Total number of boards */ -extern struct board_t *dgap_Board[MAXBOARDS]; /* Array of board structs */ -extern ulong dgap_poll_counter; /* Times the poller has run */ -extern char *dgap_config_buf; /* The config file buffer */ -extern spinlock_t dgap_dl_lock; /* Downloader spinlock */ -extern wait_queue_head_t dgap_dl_wait; /* Wait queue for downloader */ -extern int dgap_dl_action; /* Action flag for downloader */ -extern int dgap_registerttyswithsysfs; /* Should we register the */ - /* ttys with sysfs or not */ - -/* - * Global functions declared in dgap_fep5.c, but must be hidden from - * user space programs. - */ -extern void dgap_poll_tasklet(unsigned long data); -extern void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds); -extern void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds); -extern void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); -extern int dgap_param(struct tty_struct *tty); -extern void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len); -extern uint dgap_get_custom_baud(struct channel_t *ch); -extern void dgap_firmware_reset_port(struct channel_t *ch); - -#endif \ No newline at end of file +#endif From ffc1c1da7fc39e80d8a9a546fec570cd8438221a Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 19 Feb 2014 13:12:14 -0500 Subject: [PATCH 0450/1375] staging: dgap: Rename driver Renames driver file dgap_driver.c and dgap_driver.h to dgap.c and dgap.h because we are now single source and include file and better fits kernel naming conventions. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 4 ---- drivers/staging/dgap/{dgap_driver.c => dgap.c} | 2 +- drivers/staging/dgap/{dgap_driver.h => dgap.h} | 0 3 files changed, 1 insertion(+), 5 deletions(-) rename drivers/staging/dgap/{dgap_driver.c => dgap.c} (99%) rename drivers/staging/dgap/{dgap_driver.h => dgap.h} (100%) diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index b7b5778add17..0063d044ca71 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -1,5 +1 @@ obj-$(CONFIG_DGAP) += dgap.o - - -dgap-objs := dgap_driver.o - diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap.c similarity index 99% rename from drivers/staging/dgap/dgap_driver.c rename to drivers/staging/dgap/dgap.c index 21b0f90fbee8..6f07e271184d 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap.c @@ -49,7 +49,7 @@ #include #include -#include "dgap_driver.h" +#include "dgap.h" #define init_MUTEX(sem) sema_init(sem, 1) #define DECLARE_MUTEX(name) \ diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap.h similarity index 100% rename from drivers/staging/dgap/dgap_driver.h rename to drivers/staging/dgap/dgap.h From b28ec88a1d16b9db3160b19e68f0a7f5c381cbe5 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Thu, 20 Feb 2014 08:48:48 -0500 Subject: [PATCH 0451/1375] staging: dgap: Add in-kernel firmware loading support This patch adds in-kernel firmware loading support and removes support for the original userland firmware loading process. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 527 ++++++++++++++++++++++-------------- 1 file changed, 324 insertions(+), 203 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 6f07e271184d..21af5fa9545b 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -29,6 +29,32 @@ * */ +/* + * In the original out of kernel Digi dgap driver, firmware + * loading was done via user land to driver handshaking. + * + * For cards that support a concentrator (port expander), + * I believe the concentrator its self told the card which + * concentrator is actually attached and then that info + * was used to tell user land which concentrator firmware + * image was to be downloaded. I think even the BIOS or + * FEP images required could change with the connection + * of a particular concentrator. + * + * Since I have no access to any of these cards or + * concentrators, I cannot put the correct concentrator + * firmware file names into the firmware_info structure + * as is now done for the BIOS and FEP images. + * + * I think, but am not certain, that the cards supporting + * concentrators will function without them. So support + * of these cards has been left in this driver. + * + * In order to fully support those cards, they would + * either have to be acquired for dissection or maybe + * Digi International could provide some assistance. + */ +#undef DIGI_CONCENTRATORS_SUPPORTED #include #include @@ -48,6 +74,7 @@ #include #include #include +#include #include "dgap.h" @@ -191,11 +218,18 @@ static int dgap_ms_sleep(ulong ms); static char *dgap_ioctl_name(int cmd); static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len); +#ifdef DIGI_CONCENTRATORS_SUPPORTED static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len); -static void dgap_do_config_load(uchar __user *uaddr, int len); -static int dgap_after_config_loaded(void); +#endif +static int dgap_after_config_loaded(int board); static int dgap_finalize_board_init(struct board_t *brd); +static void dgap_get_vpd(struct board_t *brd); +static void dgap_do_reset_board(struct board_t *brd); +static void dgap_do_wait_for_bios(struct board_t *brd); +static void dgap_do_wait_for_fep(struct board_t *brd); +static void dgap_sysfs_create(struct board_t *brd); +static int dgap_firmware_load(struct pci_dev *pdev, int card_type); /* Driver load/unload functions */ int dgap_init_module(void); @@ -249,6 +283,24 @@ static ulong dgap_poll_time; /* Time of next poll */ static uint dgap_poll_stop; /* Used to tell poller to stop */ static struct timer_list dgap_poll_timer; +/* + SUPPORTED PRODUCTS + + Card Model Number of Ports Interface + ---------------------------------------------------------------- + Acceleport Xem 4 - 64 (EIA232 & EIA422) + Acceleport Xr 4 & 8 (EIA232) + Acceleport Xr 920 4 & 8 (EIA232) + Acceleport C/X 8 - 128 (EIA232) + Acceleport EPC/X 8 - 224 (EIA232) + Acceleport Xr/422 4 & 8 (EIA422) + Acceleport 2r/920 2 (EIA232) + Acceleport 4r/920 4 (EIA232) + Acceleport 8r/920 8 (EIA232) + + IBM 8-Port Asynchronous PCI Adapter (EIA232) + IBM 128-Port Asynchronous PCI Adapter (EIA232 & EIA422) +*/ static struct pci_device_id dgap_pci_tbl[] = { { DIGI_VID, PCI_DEVICE_XEM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, @@ -308,6 +360,35 @@ static struct pci_driver dgap_driver = { .remove = dgap_remove_one, }; +struct firmware_info { + uchar *conf_name; /* dgap.conf */ + uchar *bios_name; /* BIOS filename */ + uchar *fep_name; /* FEP filename */ + uchar *con_name; /* Concentrator filename FIXME*/ + int num; /* sequence number */ +}; + +/* + * Firmware - BIOS, FEP, and CONC filenames + */ +static struct firmware_info fw_info[] = { + { "dgap/dgap.conf", "dgap/sxbios.bin", "dgap/sxfep.bin", 0, 0 }, + { "dgap/dgap.conf", "dgap/cxpbios.bin", "dgap/cxpfep.bin", 0, 1 }, + { "dgap/dgap.conf", "dgap/cxpbios.bin", "dgap/cxpfep.bin", 0, 2 }, + { "dgap/dgap.conf", "dgap/pcibios.bin", "dgap/pcifep.bin", 0, 3 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 4 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 5 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 6 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 7 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 8 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 9 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 10 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 11 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 12 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 13 }, + { "dgap/dgap.conf", "dgap/sxbios.bin", "dgap/sxfep.bin", 0, 14 }, + {0,} +}; static char *dgap_state_text[] = { "Board Failed", @@ -477,6 +558,8 @@ int dgap_init_module(void) APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART)); + dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; + /* * Initialize global stuff */ @@ -505,6 +588,7 @@ int dgap_init_module(void) } else { dgap_create_driver_sysfiles(&dgap_driver); + dgap_driver_state = DRIVER_READY; } DPR_INIT(("Finished init_module. Returning %d\n", rc)); @@ -550,9 +634,6 @@ static int dgap_start(void) device_create(dgap_class, NULL, MKDEV(DIGI_DGAP_MAJOR, 0), NULL, "dgap_mgmt"); - device_create(dgap_class, NULL, - MKDEV(DIGI_DGAP_MAJOR, 1), - NULL, "dgap_downld"); dgap_Major_Control_Registered = TRUE; } @@ -608,6 +689,7 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc == 0) { dgap_NumBoards++; DPR_INIT(("Incrementing numboards to %d\n", dgap_NumBoards)); + rc = dgap_firmware_load(pdev, ent->driver_data); } } return rc; @@ -907,6 +989,150 @@ static int dgap_finalize_board_init(struct board_t *brd) { return(0); } +static int dgap_firmware_load(struct pci_dev *pdev, int card_type) +{ + struct board_t *brd = dgap_Board[dgap_NumBoards - 1]; + const struct firmware *fw; + int ret; + + dgap_get_vpd(brd); + dgap_do_reset_board(brd); + + if ((fw_info[card_type].conf_name) && + (dgap_driver_state == DRIVER_NEED_CONFIG_LOAD)) { + ret = request_firmware(&fw, fw_info[card_type].conf_name, + &pdev->dev); + if (ret) { + pr_err("dgap: config file %s not found\n", + fw_info[card_type].conf_name); + return ret; + } + if (!dgap_config_buf) { + dgap_config_buf = kmalloc(fw->size + 1, GFP_ATOMIC); + if (!dgap_config_buf) { + release_firmware(fw); + return -ENOMEM; + } + } + + memcpy(dgap_config_buf, fw->data, fw->size); + release_firmware(fw); + dgap_config_buf[fw->size + 1] = '\0'; + + if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) + return -EINVAL; + + dgap_driver_state = -1; + } + + ret = dgap_after_config_loaded(brd->boardnum); + if (ret) + return ret; + /* + * Match this board to a config the user created for us. + */ + brd->bd_config = + dgap_find_config(brd->type, brd->pci_bus, brd->pci_slot); + + /* + * Because the 4 port Xr products share the same PCI ID + * as the 8 port Xr products, if we receive a NULL config + * back, and this is a PAPORT8 board, retry with a + * PAPORT4 attempt as well. + */ + if (brd->type == PAPORT8 && !brd->bd_config) + brd->bd_config = + dgap_find_config(PAPORT4, brd->pci_bus, brd->pci_slot); + + if (!brd->bd_config) { + pr_err("dgap: No valid configuration found\n"); + return -EINVAL; + } + + dgap_tty_register(brd); + dgap_finalize_board_init(brd); + + if (fw_info[card_type].bios_name) { + ret = request_firmware(&fw, fw_info[card_type].bios_name, + &pdev->dev); + if (ret) { + pr_err("dgap: bios file %s not found\n", + fw_info[card_type].bios_name); + return ret; + } + dgap_do_bios_load(brd, (char *)fw->data, fw->size); + release_firmware(fw); + + /* Wait for BIOS to test board... */ + dgap_do_wait_for_bios(brd); + + if (brd->state != FINISHED_BIOS_LOAD) + return -ENXIO; + } + + if (fw_info[card_type].fep_name) { + ret = request_firmware(&fw, fw_info[card_type].fep_name, + &pdev->dev); + if (ret) { + pr_err("dgap: fep file %s not found\n", + fw_info[card_type].fep_name); + return ret; + } + dgap_do_fep_load(brd, (char *)fw->data, fw->size); + release_firmware(fw); + + /* Wait for FEP to load on board... */ + dgap_do_wait_for_fep(brd); + + if (brd->state != FINISHED_FEP_LOAD) + return -ENXIO; + } + +#ifdef DIGI_CONCENTRATORS_SUPPORTED + /* + * If this is a CX or EPCX, we need to see if the firmware + * is requesting a concentrator image from us. + */ + if ((bd->type == PCX) || (bd->type == PEPC)) { + chk_addr = (u16 *) (vaddr + DOWNREQ); + /* Nonzero if FEP is requesting concentrator image. */ + check = readw(chk_addr); + vaddr = brd->re_map_membase; + } + + if (fw_info[card_type].con_name && check && vaddr) { + ret = request_firmware(&fw, fw_info[card_type].con_name, + &pdev->dev); + if (ret) { + pr_err("dgap: conc file %s not found\n", + fw_info[card_type].con_name); + return ret; + } + /* Put concentrator firmware loading code here */ + offset = readw((u16 *) (vaddr + DOWNREQ)); + memcpy_toio(offset, fw->data, fw->size); + + dgap_do_conc_load(brd, (char *)fw->data, fw->size) + release_firmware(fw); + } +#endif + /* + * Do tty device initialization. + */ + ret = dgap_tty_init(brd); + if (ret < 0) { + dgap_tty_uninit(brd); + pr_err("dgap: Can't init tty devices (%d)\n", ret); + return ret; + } + + dgap_sysfs_create(brd); + + brd->state = BOARD_READY; + brd->dpastatus = BD_RUNNING; + + return 0; +} /* * Remap PCI memory. @@ -983,37 +1209,18 @@ static void dgap_poll_handler(ulong dummy) int i; struct board_t *brd; unsigned long lock_flags; - unsigned long lock_flags2; ulong new_time; dgap_poll_counter++; - /* - * If driver needs the config file still, - * keep trying to wake up the downloader to - * send us the file. - */ - if (dgap_driver_state == DRIVER_NEED_CONFIG_LOAD) { - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - goto schedule_poller; - } /* * Do not start the board state machine until * driver tells us its up and running, and has * everything it needs. */ - else if (dgap_driver_state != DRIVER_READY) { + if (dgap_driver_state != DRIVER_READY) goto schedule_poller; - } /* * If we have just 1 board, or the system is not SMP, @@ -4656,112 +4863,54 @@ static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return(-ENOIOCTLCMD); } } -/* - * Loads the dgap.conf config file from the user. - */ -static void dgap_do_config_load(uchar __user *uaddr, int len) + +static int dgap_after_config_loaded(int board) { - int orig_len = len; - char *to_addr; - uchar __user *from_addr = uaddr; - char buf[U2BSIZE]; - int n; - - to_addr = dgap_config_buf = kzalloc(len + 1, GFP_ATOMIC); - if (!dgap_config_buf) { - DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n")); - dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; - return; - } - - n = U2BSIZE; - while (len) { - - if (n > len) - n = len; - - if (copy_from_user((char *) &buf, from_addr, n) == -1 ) - return; - - /* Copy data from buffer to kernel memory */ - memcpy(to_addr, buf, n); - - /* increment counts */ - len -= n; - to_addr += n; - from_addr += n; - n = U2BSIZE; - } - - dgap_config_buf[orig_len] = '\0'; - - to_addr = dgap_config_buf; - dgap_parsefile(&to_addr, TRUE); - - DPR_INIT(("dgap_config_load() finish\n")); - - return; -} - - -static int dgap_after_config_loaded(void) -{ - int i = 0; - int rc = 0; + /* + * Initialize KME waitqueues... + */ + init_waitqueue_head(&(dgap_Board[board]->kme_wait)); /* - * Register our ttys, now that we have the config loaded. + * allocate flip buffer for board. */ - for (i = 0; i < dgap_NumBoards; ++i) { + dgap_Board[board]->flipbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); + if (!dgap_Board[board]->flipbuf) + return -ENOMEM; - /* - * Initialize KME waitqueues... - */ - init_waitqueue_head(&(dgap_Board[i]->kme_wait)); - - /* - * allocate flip buffer for board. - */ - dgap_Board[i]->flipbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); - dgap_Board[i]->flipflagbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); + dgap_Board[board]->flipflagbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); + if (!dgap_Board[board]->flipflagbuf) { + kfree(dgap_Board[board]->flipbuf); + return -ENOMEM; } - return rc; + return 0; } -/*======================================================================= - * - * usertoboard - copy from user space to board space. - * - *=======================================================================*/ -static int dgap_usertoboard(struct board_t *brd, char *to_addr, char __user *from_addr, int len) +/* + * Create pr and tty device entries + */ +static void dgap_sysfs_create(struct board_t *brd) { - char buf[U2BSIZE]; - int n = U2BSIZE; + struct channel_t *ch; + int j = 0; - if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return -EFAULT; + ch = brd->channels[0]; + for (j = 0; j < brd->nasync; j++, ch = brd->channels[j]) { + struct device *classp; + classp = tty_register_device(brd->SerialDriver, j, + &(ch->ch_bd->pdev->dev)); + ch->ch_tun.un_sysfs = classp; + dgap_create_tty_sysfs(&ch->ch_tun, classp); - while (len) { - if (n > len) - n = len; - - if (copy_from_user((char *) &buf, from_addr, n) == -1 ) { - return -EFAULT; - } - - /* Copy data from buffer to card memory */ - memcpy_toio(to_addr, buf, n); - - /* increment counts */ - len -= n; - to_addr += n; - from_addr += n; - n = U2BSIZE; + classp = tty_register_device(brd->PrintDriver, j, + &(ch->ch_bd->pdev->dev)); + ch->ch_pun.un_sysfs = classp; + dgap_create_tty_sysfs(&ch->ch_pun, classp); } - return 0; + dgap_create_ports_sysfiles(brd); } @@ -4792,18 +4941,13 @@ static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len) * Download bios */ offset = 0x1000; - if (dgap_usertoboard(brd, addr + offset, ubios, len) == -1 ) { - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - return; - } + memcpy_toio(addr + offset, ubios, len); writel(0x0bf00401, addr); writel(0, (addr + 4)); /* Clear the reset, and change states. */ writeb(FEPCLR, brd->re_map_port); - brd->state = WAIT_BIOS_LOAD; } @@ -4814,6 +4958,8 @@ static void dgap_do_wait_for_bios(struct board_t *brd) { uchar *addr; u16 word; + u16 err1; + u16 err2; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) return; @@ -4821,22 +4967,31 @@ static void dgap_do_wait_for_bios(struct board_t *brd) addr = brd->re_map_membase; word = readw(addr + POSTAREA); - /* Check to see if BIOS thinks board is good. (GD). */ - if (word == *(u16 *) "GD") { - DPR_INIT(("GOT GD in memory, moving states.\n")); - brd->state = FINISHED_BIOS_LOAD; - return; + /* + * It can take 5-6 seconds for a board to + * pass the bios self test and post results. + * Give it 10 seconds. + */ + brd->wait_for_bios = 0; + while (brd->wait_for_bios < 1000) { + /* Check to see if BIOS thinks board is good. (GD). */ + if (word == *(u16 *) "GD") { + DPR_INIT(("GOT GD in memory, moving states.\n")); + brd->state = FINISHED_BIOS_LOAD; + return; + } + msleep_interruptible(10); + brd->wait_for_bios++; + word = readw(addr + POSTAREA); } - /* Give up on board after too long of time taken */ - if (brd->wait_for_bios++ > 5000) { - u16 err1 = readw(addr + SEQUENCE); - u16 err2 = readw(addr + ERROR); - APR(("***WARNING*** %s failed diagnostics. Error #(%x,%x).\n", - brd->name, err1, err2)); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - } + /* Gave up on board after too long of time taken */ + err1 = readw(addr + SEQUENCE); + err2 = readw(addr + ERROR); + APR(("***WARNING*** %s failed diagnostics. Error #(%x,%x).\n", + brd->name, err1, err2)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOBIOS; } @@ -4844,7 +4999,7 @@ static void dgap_do_wait_for_bios(struct board_t *brd) * Copies the FEP code from the user to the board, * and starts the FEP running. */ -static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) +static void dgap_do_fep_load(struct board_t *brd, uchar *ufep, int len) { uchar *addr; uint offset; @@ -4860,11 +5015,7 @@ static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) * Download FEP */ offset = 0x1000; - if (dgap_usertoboard(brd, addr + offset, ufep, len) == -1 ) { - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - return; - } + memcpy_toio(addr + offset, ufep, len); /* * If board is a concentrator product, we need to give @@ -4889,9 +5040,6 @@ static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) writel(0xbfc01004, (addr + 0xc34)); writel(0x3, (addr + 0xc30)); - /* change states. */ - brd->state = WAIT_FEP_LOAD; - DPR_INIT(("dgap_do_fep_load() for board %s : finish\n", brd->name)); } @@ -4904,42 +5052,45 @@ static void dgap_do_wait_for_fep(struct board_t *brd) { uchar *addr; u16 word; + u16 err1; + u16 err2; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) return; addr = brd->re_map_membase; - - DPR_INIT(("dgap_do_wait_for_fep() for board %s : start. addr: %p\n", brd->name, addr)); - word = readw(addr + FEPSTAT); - /* Check to see if FEP is up and running now. */ - if (word == *(u16 *) "OS") { - DPR_INIT(("GOT OS in memory for board %s, moving states.\n", brd->name)); - brd->state = FINISHED_FEP_LOAD; + /* + * It can take 2-3 seconds for the FEP to + * be up and running. Give it 5 secs. + */ + brd->wait_for_fep = 0; + while (brd->wait_for_fep < 500) { + /* Check to see if FEP is up and running now. */ + if (word == *(u16 *) "OS") { + brd->state = FINISHED_FEP_LOAD; + /* + * Check to see if the board can support FEP5+ commands. + */ + word = readw(addr + FEP5_PLUS); + if (word == *(u16 *) "5A") + brd->bd_flags |= BD_FEP5PLUS; - /* - * Check to see if the board can support FEP5+ commands. - */ - word = readw(addr + FEP5_PLUS); - if (word == *(u16 *) "5A") { - DPR_INIT(("GOT 5A in memory for board %s, board supports extended FEP5 commands.\n", brd->name)); - brd->bd_flags |= BD_FEP5PLUS; + return; } - - return; + msleep_interruptible(10); + brd->wait_for_fep++; + word = readw(addr + FEPSTAT); } - /* Give up on board after too long of time taken */ - if (brd->wait_for_fep++ > 5000) { - u16 err1 = readw(addr + SEQUENCE); - u16 err2 = readw(addr + ERROR); - APR(("***WARNING*** FEPOS for %s not functioning. Error #(%x,%x).\n", - brd->name, err1, err2)); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - } + /* Gave up on board after too long of time taken */ + err1 = readw(addr + SEQUENCE); + err2 = readw(addr + ERROR); + APR(("***WARNING*** FEPOS for %s not functioning. Error #(%x,%x).\n", + brd->name, err1, err2)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; DPR_INIT(("dgap_do_wait_for_fep() for board %s : finish\n", brd->name)); } @@ -5003,6 +5154,7 @@ failed: } +#ifdef DIGI_CONCENTRATORS_SUPPORTED /* * Sends a concentrator image into the FEP5 board. */ @@ -5019,19 +5171,14 @@ static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) offset = readw((u16 *) (vaddr + DOWNREQ)); to_dp = (struct downld_t *) (vaddr + (int) offset); - - /* - * The image was already read into kernel space, - * we do NOT need a user space read here - */ - memcpy_toio((char *) to_dp, uaddr, sizeof(struct downld_t)); + memcpy_toio(to_dp, uaddr, len); /* Tell card we have data for it */ writew(0, vaddr + (DOWNREQ)); brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; } - +#endif #define EXPANSION_ROM_SIZE (64 * 1024) #define FEP5_ROM_MAGIC (0xFEFFFFFF) @@ -5148,8 +5295,6 @@ static void dgap_poll_tasklet(unsigned long data) ulong lock_flags2; char *vaddr; u16 head, tail; - u16 *chk_addr; - u16 check = 0; if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) { APR(("dgap_poll_tasklet() - NULL or bad bd.\n")); @@ -5183,30 +5328,6 @@ static void dgap_poll_tasklet(unsigned long data) goto out; } - /* - * If this is a CX or EPCX, we need to see if the firmware - * is requesting a concentrator image from us. - */ - if ((bd->type == PCX) || (bd->type == PEPC)) { - chk_addr = (u16 *) (vaddr + DOWNREQ); - check = readw(chk_addr); - /* Nonzero if FEP is requesting concentrator image. */ - if (check) { - if (bd->conc_dl_status == NO_PENDING_CONCENTRATOR_REQUESTS) - bd->conc_dl_status = NEED_CONCENTRATOR; - /* - * Signal downloader, its got some work to do. - */ - DGAP_LOCK(dgap_dl_lock, lock_flags2); - if (dgap_dl_action != 1) { - dgap_dl_action = 1; - wake_up_interruptible(&dgap_dl_wait); - } - DGAP_UNLOCK(dgap_dl_lock, lock_flags2); - - } - } - eaddr = (struct ev_t *) (vaddr + EVBUF); /* Get our head and tail */ From 4c6978d304a8b583f946f9de86633c06653a2ed4 Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Mon, 24 Feb 2014 13:08:20 -0700 Subject: [PATCH 0452/1375] staging/rtl8192e: Remove unused code Remove unused #defines, structure, and inlined functions for the rtl8192e driver. Compile tested only. Signed-off-by: Jon Mason Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 52 --------------------- 1 file changed, 52 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h index 356aec437963..4b94653c50d9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h @@ -28,31 +28,6 @@ #include #include -static inline void NdisRawWritePortUlong(u32 port, u32 val) -{ - outl(val, port); -} - -static inline void NdisRawWritePortUchar(u32 port, u8 val) -{ - outb(val, port); -} - -static inline void NdisRawReadPortUchar(u32 port, u8 *pval) -{ - *pval = inb(port); -} - -static inline void NdisRawReadPortUshort(u32 port, u16 *pval) -{ - *pval = inw(port); -} - -static inline void NdisRawReadPortUlong(u32 port, u32 *pval) -{ - *pval = inl(port); -} - struct mp_adapter { u8 LinkCtrlReg; @@ -70,33 +45,6 @@ struct mp_adapter { u8 PciBridgeLinkCtrlReg; }; -struct rt_pci_capab_header { - unsigned char CapabilityID; - unsigned char Next; -}; - -#define PCI_MAX_BRIDGE_NUMBER 255 -#define PCI_MAX_DEVICES 32 -#define PCI_MAX_FUNCTION 8 - -#define PCI_CONF_ADDRESS 0x0CF8 -#define PCI_CONF_DATA 0x0CFC - -#define PCI_CLASS_BRIDGE_DEV 0x06 -#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 - -#define U1DONTCARE 0xFF -#define U2DONTCARE 0xFFFF -#define U4DONTCARE 0xFFFFFFFF - -#define INTEL_VENDOR_ID 0x8086 -#define SIS_VENDOR_ID 0x1039 -#define ATI_VENDOR_ID 0x1002 -#define ATI_DEVICE_ID 0x7914 -#define AMD_VENDOR_ID 0x1022 - -#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 - struct net_device; bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev); From f39b8534d3fd2f107dc50a9f7099c7ef4b3df6a3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 18:35:22 +0000 Subject: [PATCH 0453/1375] staging: vt6656: PIPEnsInterruptRead use usb_fill_int_urb Change to usb_fill_int_urb which has int_interval. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 119f65603241..845a8a12a3e4 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -312,15 +312,15 @@ int PIPEnsInterruptRead(struct vnt_private *pDevice) // Now that we have created the urb, we will send a // request to the USB device object. // - pDevice->pInterruptURB->interval = pDevice->int_interval; -usb_fill_bulk_urb(pDevice->pInterruptURB, + usb_fill_int_urb(pDevice->pInterruptURB, pDevice->usb, usb_rcvbulkpipe(pDevice->usb, 1), - (void *) pDevice->intBuf.pDataBuf, + pDevice->intBuf.pDataBuf, MAX_INTERRUPT_SIZE, s_nsInterruptUsbIoCompleteRead, - pDevice); + pDevice, + pDevice->int_interval); ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); if (ntStatus != 0) { From 59858f5e91da4826102f5931a7302529e09dbb10 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 18:36:37 +0000 Subject: [PATCH 0454/1375] staging: vt6656: PIPEnsInterruptRead set intBuf.bInUse to false. set intBuf.bInUse to false on return error. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 845a8a12a3e4..1a0b436020a6 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -323,9 +323,11 @@ int PIPEnsInterruptRead(struct vnt_private *pDevice) pDevice->int_interval); ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); - if (ntStatus != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus); - } + if (ntStatus) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Submit int URB failed %d\n", ntStatus); + pDevice->intBuf.bInUse = false; + } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----s_nsStartInterruptUsbRead Return(%x)\n",ntStatus); return ntStatus; From 5f38b783101eb88318f0ee8b4adbb2a064117811 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 18:37:32 +0000 Subject: [PATCH 0455/1375] staging: vt6656: clean up PIPEnsInterruptRead. Remove comments, white space and camel case. Camel case changes pDevice -> priv ntStatus -> status Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 47 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 1a0b436020a6..9f4d1a27b20a 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -295,42 +295,39 @@ static void s_nsControlInUsbIoCompleteRead(struct urb *urb) * */ -int PIPEnsInterruptRead(struct vnt_private *pDevice) +int PIPEnsInterruptRead(struct vnt_private *priv) { - int ntStatus = STATUS_FAILURE; + int status = STATUS_FAILURE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartInterruptUsbRead()\n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "---->s_nsStartInterruptUsbRead()\n"); - if(pDevice->intBuf.bInUse == true){ - return (STATUS_FAILURE); - } - pDevice->intBuf.bInUse = true; -// pDevice->bEventAvailable = false; - pDevice->ulIntInPosted++; + if (priv->intBuf.bInUse == true) + return STATUS_FAILURE; - // - // Now that we have created the urb, we will send a - // request to the USB device object. - // + priv->intBuf.bInUse = true; + priv->ulIntInPosted++; - usb_fill_int_urb(pDevice->pInterruptURB, - pDevice->usb, - usb_rcvbulkpipe(pDevice->usb, 1), - pDevice->intBuf.pDataBuf, + usb_fill_int_urb(priv->pInterruptURB, + priv->usb, + usb_rcvbulkpipe(priv->usb, 1), + priv->intBuf.pDataBuf, MAX_INTERRUPT_SIZE, s_nsInterruptUsbIoCompleteRead, - pDevice, - pDevice->int_interval); + priv, + priv->int_interval); - ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); - if (ntStatus) { + status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); + if (status) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit int URB failed %d\n", ntStatus); - pDevice->intBuf.bInUse = false; + "Submit int URB failed %d\n", status); + priv->intBuf.bInUse = false; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----s_nsStartInterruptUsbRead Return(%x)\n",ntStatus); - return ntStatus; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "<----s_nsStartInterruptUsbRead Return(%x)\n", status); + + return status; } /* From f764e00d16495800526fbfb4dc03160e64c9081a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 18:39:09 +0000 Subject: [PATCH 0456/1375] staging: vt6656: Replace typedef struct INT_BUFFER, *PINT_BUFFER Replace with struct vnt_interrupt_buffer. Using only the live member of old structure pDataBuf -> data_buf bInUse -> in_use uDataLen is unused and dropped. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 12 +++++------- drivers/staging/vt6656/int.c | 6 +++--- drivers/staging/vt6656/main_usb.c | 8 ++++---- drivers/staging/vt6656/usbpipe.c | 14 +++++++------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index e5f0be3b4ae4..33e5e3400189 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -206,12 +206,10 @@ typedef struct _DEFAULT_CONFIG { /* * Structure to keep track of USB interrupt packets */ -typedef struct { - unsigned int uDataLen; - u8 * pDataBuf; - /* struct urb *pUrb; */ - bool bInUse; -} INT_BUFFER, *PINT_BUFFER; +struct vnt_interrupt_buffer { + u8 *data_buf; + bool in_use; +}; /*++ NDIS related */ @@ -420,7 +418,7 @@ struct vnt_private { struct vnt_tx_pkt_info pkt_info[16]; /* Variables to track resources for the Interrupt In Pipe */ - INT_BUFFER intBuf; + struct vnt_interrupt_buffer int_buf; int bEventAvailable; /* default config from file by user setting */ diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index 34c45280a9c1..cca56b2f243d 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -84,7 +84,7 @@ void INTnsProcessData(struct vnt_private *priv) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); - int_data = (struct vnt_interrupt_data *)priv->intBuf.pDataBuf; + int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf; if (int_data->tsr0 & TSR_VALID) { if (int_data->tsr0 & (TSR_TMO | TSR_RETRYTMO)) @@ -178,8 +178,8 @@ void INTnsProcessData(struct vnt_private *priv) bScheduleCommand((void *) priv, WLAN_CMD_RADIO, NULL); - priv->intBuf.uDataLen = 0; - priv->intBuf.bInUse = false; + + priv->int_buf.in_use = false; stats->tx_errors = priv->wstats.discard.retries; stats->tx_dropped = priv->wstats.discard.retries; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index bea1ad93336a..713844fa8320 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -800,8 +800,8 @@ static void usb_device_reset(struct vnt_private *pDevice) static void device_free_int_bufs(struct vnt_private *pDevice) { - kfree(pDevice->intBuf.pDataBuf); - return; + kfree(pDevice->int_buf.data_buf); + return; } static bool device_alloc_bufs(struct vnt_private *pDevice) @@ -873,8 +873,8 @@ static bool device_alloc_bufs(struct vnt_private *pDevice) goto free_rx_tx; } - pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); - if (pDevice->intBuf.pDataBuf == NULL) { + pDevice->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); + if (pDevice->int_buf.data_buf == NULL) { DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n"); usb_free_urb(pDevice->pInterruptURB); goto free_rx_tx; diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 9f4d1a27b20a..79e38b7832de 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -302,16 +302,16 @@ int PIPEnsInterruptRead(struct vnt_private *priv) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->s_nsStartInterruptUsbRead()\n"); - if (priv->intBuf.bInUse == true) + if (priv->int_buf.in_use == true) return STATUS_FAILURE; - priv->intBuf.bInUse = true; + priv->int_buf.in_use = true; priv->ulIntInPosted++; usb_fill_int_urb(priv->pInterruptURB, priv->usb, usb_rcvbulkpipe(priv->usb, 1), - priv->intBuf.pDataBuf, + priv->int_buf.data_buf, MAX_INTERRUPT_SIZE, s_nsInterruptUsbIoCompleteRead, priv, @@ -321,7 +321,7 @@ int PIPEnsInterruptRead(struct vnt_private *priv) if (status) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Submit int URB failed %d\n", status); - priv->intBuf.bInUse = false; + priv->int_buf.in_use = false; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO @@ -360,7 +360,7 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - priv->intBuf.bInUse = false; + priv->int_buf.in_use = false; return; default: break; @@ -373,7 +373,7 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) if (status != STATUS_SUCCESS) { priv->ulBulkInError++; - priv->intBuf.bInUse = false; + priv->int_buf.in_use = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "IntUSBIoCompleteControl STATUS = %d\n", status); @@ -389,7 +389,7 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Submit int URB failed %d\n", status); } else { - priv->intBuf.bInUse = true; + priv->int_buf.in_use = true; } return; From edd20e964072e1bfccee06362e55148d6a1117b5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 19:34:18 +0000 Subject: [PATCH 0457/1375] staging: vt6656: Move device_set_multi code call to vRunCommand device_set_multi is an atomic call, in order to reduce atomic area of driver move code to be called from vRunCommand. Later the atomic area of vRunCommand can be reduced. Change existing code in device_set_multi to new function vnt_configure_filter minus its locks. Change device_set_multi to call bScheduleCommand device_set_multi is nolonger called from device open. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 + drivers/staging/vt6656/main_usb.c | 20 ++++++++++++++------ drivers/staging/vt6656/wcmd.c | 9 +++++++++ drivers/staging/vt6656/wcmd.h | 4 +++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 33e5e3400189..7e774b239a2f 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -789,5 +789,6 @@ struct vnt_private { (fMP_DISCONNECTED | fMP_RESET_IN_PROGRESS | fMP_HALT_IN_PROGRESS | fMP_INIT_IN_PROGRESS | fMP_SURPRISE_REMOVED)) == 0) int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF); +void vnt_configure_filter(struct vnt_private *); #endif diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 713844fa8320..77830509c52e 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -974,8 +974,6 @@ static int device_open(struct net_device *dev) goto free_all; } - device_set_multi(pDevice->dev); - /* init for key management */ KeyvInitTable(pDevice,&pDevice->sKey); memcpy(pDevice->vnt_mgmt.abyMACAddr, @@ -1349,14 +1347,26 @@ static int Read_config_file(struct vnt_private *pDevice) static void device_set_multi(struct net_device *dev) { struct vnt_private *priv = netdev_priv(dev); + unsigned long flags; + + if (priv->flags & DEVICE_FLAGS_OPENED) { + spin_lock_irqsave(&priv->lock, flags); + + bScheduleCommand(priv, WLAN_CMD_CONFIGURE_FILTER, NULL); + + spin_unlock_irqrestore(&priv->lock, flags); + } +} + +void vnt_configure_filter(struct vnt_private *priv) +{ + struct net_device *dev = priv->dev; struct vnt_manager *mgmt = &priv->vnt_mgmt; struct netdev_hw_addr *ha; u64 mc_filter = 0; u8 tmp = 0; int rc; - spin_lock_irq(&priv->lock); - rc = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, MAC_REG_RCR, MESSAGE_REQUEST_MACREG, 1, &tmp); if (rc == 0) @@ -1403,8 +1413,6 @@ static void device_set_multi(struct net_device *dev) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "priv->byRxMode out= %x\n", priv->byRxMode); - - spin_unlock_irq(&priv->lock); } static struct net_device_stats *device_get_stats(struct net_device *dev) diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 6b9522914634..8c702c379739 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -909,6 +909,10 @@ void vRunCommand(struct work_struct *work) s_bCommandComplete(pDevice); break; + case WLAN_CMD_CONFIGURE_FILTER_START: + vnt_configure_filter(pDevice); + s_bCommandComplete(pDevice); + break; default: s_bCommandComplete(pDevice); break; @@ -1009,6 +1013,11 @@ static int s_bCommandComplete(struct vnt_private *pDevice) pDevice->eCommandState = WLAN_CMD_11H_CHSW_START; break; + case WLAN_CMD_CONFIGURE_FILTER: + pDevice->eCommandState = + WLAN_CMD_CONFIGURE_FILTER_START; + break; + default: break; } diff --git a/drivers/staging/vt6656/wcmd.h b/drivers/staging/vt6656/wcmd.h index caf2684ce915..736572101bad 100644 --- a/drivers/staging/vt6656/wcmd.h +++ b/drivers/staging/vt6656/wcmd.h @@ -51,7 +51,8 @@ typedef enum tagCMD_CODE { WLAN_CMD_REMOVE_ALLKEY, WLAN_CMD_MAC_DISPOWERSAVING, WLAN_CMD_11H_CHSW, - WLAN_CMD_RUN_AP + WLAN_CMD_RUN_AP, + WLAN_CMD_CONFIGURE_FILTER } CMD_CODE, *PCMD_CODE; #define CMD_Q_SIZE 32 @@ -96,6 +97,7 @@ typedef enum tagCMD_STATE { WLAN_CMD_REMOVE_ALLKEY_START, WLAN_CMD_MAC_DISPOWERSAVING_START, WLAN_CMD_11H_CHSW_START, + WLAN_CMD_CONFIGURE_FILTER_START, WLAN_CMD_IDLE } CMD_STATE, *PCMD_STATE; From 2ae2777c44d75d7754a80483ecaefc23cf5c41dc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 19:35:16 +0000 Subject: [PATCH 0458/1375] staging: vt6656: vRunCommand remove multi calls to s_bCommandComplete. Remove calls with break s_bCommandComplete(pDevice); spin_unlock_irq(&pDevice->lock); return; Add single call to s_bCommandComplete; Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/wcmd.c | 70 +++++++++-------------------------- 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 8c702c379739..3cf3f24247a3 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -293,17 +293,11 @@ void vRunCommand(struct work_struct *work) case WLAN_CMD_SCAN_START: pDevice->byReAssocCount = 0; - if (pDevice->bRadioOff == true) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } + if (pDevice->bRadioOff == true) + break; - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } + if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) + break; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID; @@ -311,16 +305,12 @@ void vRunCommand(struct work_struct *work) pMgmt->uScanChannel = pDevice->byMinChannel; if (pMgmt->uScanChannel > pDevice->byMaxChannel) { pDevice->eCommandState = WLAN_CMD_SCAN_END; - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; + break; } else { if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d\n", pMgmt->uScanChannel); pMgmt->uScanChannel++; - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; + break; } if (pMgmt->uScanChannel == pDevice->byMinChannel) { // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark @@ -420,16 +410,13 @@ void vRunCommand(struct work_struct *work) memset(&wrqu, 0, sizeof(wrqu)); wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL); - s_bCommandComplete(pDevice); break; case WLAN_CMD_DISASSOCIATE_START: pDevice->byReAssocCount = 0; if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState != WMAC_STATE_ASSOC)) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; + break; } else { pDevice->bwextstep0 = false; pDevice->bwextstep1 = false; @@ -458,17 +445,14 @@ void vRunCommand(struct work_struct *work) netif_stop_queue(pDevice->dev); if (pDevice->bNeedRadioOFF == true) CARDbRadioPowerOff(pDevice); - s_bCommandComplete(pDevice); + break; case WLAN_CMD_SSID_START: pDevice->byReAssocCount = 0; - if (pDevice->bRadioOff == true) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } + if (pDevice->bRadioOff == true) + break; memcpy(pMgmt->abyAdHocSSID, pMgmt->abyDesireSSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN); @@ -489,11 +473,9 @@ void vRunCommand(struct work_struct *work) if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { if (pItemSSID->len == pItemSSIDCurr->len) { - if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } + if (!memcmp(pItemSSID->abySSID, + pItemSSIDCurr->abySSID, pItemSSID->len)) + break; } netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; @@ -582,7 +564,6 @@ void vRunCommand(struct work_struct *work) } } } - s_bCommandComplete(pDevice); break; case WLAN_AUTHENTICATE_WAIT: @@ -612,7 +593,6 @@ void vRunCommand(struct work_struct *work) } pDevice->byLinkWaitCount = 0; - s_bCommandComplete(pDevice); break; case WLAN_ASSOCIATE_WAIT: @@ -647,7 +627,6 @@ void vRunCommand(struct work_struct *work) return; } - s_bCommandComplete(pDevice); break; case WLAN_CMD_AP_MODE_START: @@ -683,7 +662,6 @@ void vRunCommand(struct work_struct *work) ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); schedule_delayed_work(&pDevice->second_callback_work, HZ); } - s_bCommandComplete(pDevice); break; case WLAN_CMD_TX_PSPACKET_START: @@ -738,8 +716,6 @@ void vRunCommand(struct work_struct *work) pMgmt->sNodeDBTable[ii].bRxPSPoll = false; } } - - s_bCommandComplete(pDevice); break; case WLAN_CMD_RADIO_START: @@ -760,11 +736,8 @@ void vRunCommand(struct work_struct *work) 1, &byTmp); - if (ntStatus != STATUS_SUCCESS) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } + if (ntStatus != STATUS_SUCCESS) + break; if ((byTmp & GPIO3_DATA) == 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n"); // Old commands are useless. @@ -833,7 +806,6 @@ void vRunCommand(struct work_struct *work) } } - s_bCommandComplete(pDevice); break; case WLAN_CMD_CHANGE_BBSENSITIVITY_START: @@ -843,24 +815,20 @@ void vRunCommand(struct work_struct *work) BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent); pDevice->bStopDataPkt = false; - s_bCommandComplete(pDevice); break; case WLAN_CMD_TBTT_WAKEUP_START: PSbIsNextTBTTWakeUp(pDevice); - s_bCommandComplete(pDevice); break; case WLAN_CMD_BECON_SEND_START: bMgrPrepareBeaconToSend(pDevice, pMgmt); - s_bCommandComplete(pDevice); break; case WLAN_CMD_SETPOWER_START: RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel); - s_bCommandComplete(pDevice); break; case WLAN_CMD_CHANGE_ANTENNA_START: @@ -878,12 +846,10 @@ void vRunCommand(struct work_struct *work) else BBvSetAntennaMode(pDevice, ANT_RXA); } - s_bCommandComplete(pDevice); break; case WLAN_CMD_REMOVE_ALLKEY_START: KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID); - s_bCommandComplete(pDevice); break; case WLAN_CMD_MAC_DISPOWERSAVING_START: @@ -898,7 +864,6 @@ void vRunCommand(struct work_struct *work) NULL ); } - s_bCommandComplete(pDevice); break; case WLAN_CMD_11H_CHSW_START: @@ -906,18 +871,17 @@ void vRunCommand(struct work_struct *work) pDevice->bChannelSwitch = false; pMgmt->uCurrChannel = pDevice->byNewChannel; pDevice->bStopDataPkt = false; - s_bCommandComplete(pDevice); break; case WLAN_CMD_CONFIGURE_FILTER_START: vnt_configure_filter(pDevice); - s_bCommandComplete(pDevice); break; default: - s_bCommandComplete(pDevice); break; } //switch + s_bCommandComplete(pDevice); + spin_unlock_irq(&pDevice->lock); return; } From 1c398a38fbc73b640b0e546d27e3e1b5610ea8e5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 21:50:14 +0000 Subject: [PATCH 0459/1375] staging: vt6656: s_nsBulkOutIoCompleteWrite reorganise variable order. Declare in order of pointer use. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 79e38b7832de..16acc9a77e4e 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -607,21 +607,14 @@ int PIPEnsSendBulkOut(struct vnt_private *pDevice, static void s_nsBulkOutIoCompleteWrite(struct urb *urb) { - struct vnt_private *pDevice; + struct vnt_usb_send_context *pContext = + (struct vnt_usb_send_context *)urb->context; + struct vnt_private *pDevice = pContext->pDevice; + CONTEXT_TYPE ContextType = pContext->Type; + unsigned long ulBufLen = pContext->uBufLen; int status; - CONTEXT_TYPE ContextType; - unsigned long ulBufLen; - struct vnt_usb_send_context *pContext; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); - // - // The context given to IoSetCompletionRoutine is an USB_CONTEXT struct - // - pContext = (struct vnt_usb_send_context *)urb->context; - - pDevice = pContext->pDevice; - ContextType = pContext->Type; - ulBufLen = pContext->uBufLen; if (!netif_device_present(pDevice->dev)) return; From e8152bfb51dbf8e3d2e6db3b3e540df6d634993b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 21:53:35 +0000 Subject: [PATCH 0460/1375] staging: vt6656: s_nsBulkOutIoCompleteWrite add error handling, change pContext->bBoolInUse to false on connection errors. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 16acc9a77e4e..61d822021209 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -616,6 +616,19 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); + switch (urb->status) { + case 0: + case -ETIMEDOUT: + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + pContext->bBoolInUse = false; + return; + default: + break; + } + if (!netif_device_present(pDevice->dev)) return; From 21aa212ca6a62b009d6be7d8223f681f4d055bd7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 21:54:45 +0000 Subject: [PATCH 0461/1375] staging: vt6656: clean up s_nsBulkOutIoCompleteWrite. Remove commented out, white space and camel case. Camel case changes pContext -> context pDevice -> priv ContextType -> context_type ulBufLen -> buf_len Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 88 ++++++++++++++++---------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 61d822021209..0ae5d20f3f34 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -607,14 +607,14 @@ int PIPEnsSendBulkOut(struct vnt_private *pDevice, static void s_nsBulkOutIoCompleteWrite(struct urb *urb) { - struct vnt_usb_send_context *pContext = + struct vnt_usb_send_context *context = (struct vnt_usb_send_context *)urb->context; - struct vnt_private *pDevice = pContext->pDevice; - CONTEXT_TYPE ContextType = pContext->Type; - unsigned long ulBufLen = pContext->uBufLen; + struct vnt_private *priv = context->pDevice; + CONTEXT_TYPE context_type = context->Type; + unsigned long buf_len = context->uBufLen; int status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); switch (urb->status) { case 0: @@ -623,58 +623,56 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - pContext->bBoolInUse = false; + context->bBoolInUse = false; return; default: break; } - if (!netif_device_present(pDevice->dev)) - return; + if (!netif_device_present(priv->dev)) + return; - // - // Perform various IRP, URB, and buffer 'sanity checks' - // - status = urb->status; + status = urb->status; - if(status == STATUS_SUCCESS) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Write %d bytes\n",(int)ulBufLen); - pDevice->ulBulkOutBytesWrite += ulBufLen; - pDevice->ulBulkOutContCRCError = 0; - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK Out failed %d\n", status); - pDevice->ulBulkOutError++; - } + if (status == STATUS_SUCCESS) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Write %d bytes\n", (int)buf_len); + priv->ulBulkOutBytesWrite += buf_len; + priv->ulBulkOutContCRCError = 0; + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "BULK Out failed %d\n", status); + priv->ulBulkOutError++; + } -// pDevice->ulCheckForHangCount = 0; -// pDevice->pPendingBulkOutContext = NULL; - if ( CONTEXT_DATA_PACKET == ContextType ) { - // Indicate to the protocol the status of the sent packet and return - // ownership of the packet. - if (pContext->pPacket != NULL) { - dev_kfree_skb_irq(pContext->pPacket); - pContext->pPacket = NULL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"tx %d bytes\n",(int)ulBufLen); - } + if (CONTEXT_DATA_PACKET == context_type) { + if (context->pPacket != NULL) { + dev_kfree_skb_irq(context->pPacket); + context->pPacket = NULL; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "tx %d bytes\n", (int)buf_len); + } - pDevice->dev->trans_start = jiffies; + priv->dev->trans_start = jiffies; - if (status == STATUS_SUCCESS) { - pDevice->packetsSent++; - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send USB error! [%08xh]\n", status); - pDevice->packetsSentDropped++; - } + if (status == STATUS_SUCCESS) { + priv->packetsSent++; + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Send USB error! [%08xh]\n", status); + priv->packetsSentDropped++; + } - } - if (pDevice->bLinkPass == true) { - if (netif_queue_stopped(pDevice->dev)) - netif_wake_queue(pDevice->dev); - } - pContext->bBoolInUse = false; + } - return; + if (priv->bLinkPass == true) { + if (netif_queue_stopped(priv->dev)) + netif_wake_queue(priv->dev); + } + + context->bBoolInUse = false; + + return; } From 1450ba62db65db9ad8696e369a67f5dc963a98b1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 19 Feb 2014 21:56:33 +0000 Subject: [PATCH 0462/1375] staging: vt6656: Remove typedef enum _CONTEXT_TYPE Replace with enum assign as u8 type. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 10 +++++----- drivers/staging/vt6656/rxtx.c | 10 +++++----- drivers/staging/vt6656/usbpipe.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 7e774b239a2f..54c6383c5a7d 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -158,10 +158,10 @@ typedef enum __device_msg_level { /* * Enum of context types for SendPacket */ -typedef enum _CONTEXT_TYPE { - CONTEXT_DATA_PACKET = 1, - CONTEXT_MGMT_PACKET -} CONTEXT_TYPE; +enum { + CONTEXT_DATA_PACKET = 1, + CONTEXT_MGMT_PACKET +}; /* RCB (Receive Control Block) */ struct vnt_rcb { @@ -180,7 +180,7 @@ struct vnt_usb_send_context { struct sk_buff *pPacket; struct urb *pUrb; unsigned int uBufLen; - CONTEXT_TYPE Type; + u8 type; struct ethhdr sEthHeader; void *Next; bool bBoolInUse; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 92146e503156..ba0184a303f7 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1610,7 +1610,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pTX_Buffer->byType = 0x00; pContext->pPacket = NULL; - pContext->Type = CONTEXT_MGMT_PACKET; + pContext->type = CONTEXT_MGMT_PACKET; pContext->uBufLen = (u16)cbReqCount + 4; //USB header if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { @@ -1702,7 +1702,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTX_Buffer->byType = 0x01; pContext->pPacket = NULL; - pContext->Type = CONTEXT_MGMT_PACKET; + pContext->type = CONTEXT_MGMT_PACKET; pContext->uBufLen = (u16)cbReqCount + 4; //USB header PIPEnsSendBulkOut(pDevice,pContext); @@ -2050,7 +2050,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pTX_Buffer->byType = 0x00; pContext->pPacket = skb; - pContext->Type = CONTEXT_MGMT_PACKET; + pContext->type = CONTEXT_MGMT_PACKET; pContext->uBufLen = (u16)cbReqCount + 4; //USB header if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { @@ -2440,7 +2440,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, pTX_Buffer->wTxByteCount = (u16)BytesToWrite; pContext->pPacket = skb; - pContext->Type = CONTEXT_DATA_PACKET; + pContext->type = CONTEXT_DATA_PACKET; pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), @@ -2594,7 +2594,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, pTX_Buffer->wTxByteCount = (u16)BytesToWrite; pContext->pPacket = NULL; - pContext->Type = CONTEXT_DATA_PACKET; + pContext->type = CONTEXT_DATA_PACKET; pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 0ae5d20f3f34..1fc382d59a3f 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -610,7 +610,7 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) struct vnt_usb_send_context *context = (struct vnt_usb_send_context *)urb->context; struct vnt_private *priv = context->pDevice; - CONTEXT_TYPE context_type = context->Type; + u8 context_type = context->type; unsigned long buf_len = context->uBufLen; int status; From cc0f58a9b98f14aa09d2a8cb81a394bee8d7f2f4 Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Mon, 24 Feb 2014 22:19:42 +0530 Subject: [PATCH 0463/1375] Staging: comedi: Fix line length exceeding 80 characters Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ac1edd9d1e21..a819e543ed30 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1481,7 +1481,8 @@ static int do_cmd_ioctl(struct comedi_device *dev, async->cmd.data = NULL; /* load channel/gain list */ async->cmd.chanlist = memdup_user(user_chanlist, - async->cmd.chanlist_len * sizeof(int)); + async->cmd.chanlist_len * + sizeof(int)); if (IS_ERR(async->cmd.chanlist)) { ret = PTR_ERR(async->cmd.chanlist); async->cmd.chanlist = NULL; From 85b3842bd2d4f295b24254464eb103f85f9e5663 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Fri, 21 Feb 2014 21:20:29 -0600 Subject: [PATCH 0464/1375] Staging: comedi: addi-data: comment cleanup in hwdrv_apci035.c This patch further cleans up the comments in hwdrv_apci035.c, converting them to kernel style and removing some commented conditional statements that are unused. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci035.c | 110 ++++++------------ 1 file changed, 34 insertions(+), 76 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 8ce3335422cd..7c405354d0f2 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -188,17 +188,14 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /************************/ + /* Set the reload value */ - /************************/ outl(data[3], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 4); - /*********************/ + /* Set the time unit */ - /*********************/ outl(data[2], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 8); if (data[0] == ADDIDATA_TIMER) { - /******************************/ /* Set the mode : */ /* - Disable the hardware */ /* - Disable the counter mode */ @@ -206,23 +203,19 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, /* - Disable the reset */ /* - Enable the timer mode */ /* - Set the timer mode */ - /******************************/ ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL; - } /* if (data[0] == ADDIDATA_TIMER) */ - else { + } else { if (data[0] == ADDIDATA_WATCHDOG) { - /******************************/ /* Set the mode : */ /* - Disable the hardware */ /* - Disable the counter mode */ /* - Disable the warning */ /* - Disable the reset */ /* - Disable the timer mode */ - /******************************/ ui_Command = ui_Command & 0xFFF819E2UL; @@ -234,73 +227,61 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /********************************/ + /* Disable the hardware trigger */ - /********************************/ ui_Command = ui_Command & 0xFFFFF89FUL; if (data[4] == ADDIDATA_ENABLE) { - /**********************************/ + /* Set the hardware trigger level */ - /**********************************/ ui_Command = ui_Command | (data[5] << 5); } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*****************************/ + /* Disable the hardware gate */ - /*****************************/ ui_Command = ui_Command & 0xFFFFF87FUL; if (data[6] == ADDIDATA_ENABLE) { - /*******************************/ + /* Set the hardware gate level */ - /*******************************/ ui_Command = ui_Command | (data[7] << 7); } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*******************************/ + /* Disable the hardware output */ - /*******************************/ ui_Command = ui_Command & 0xFFFFF9FBUL; - /*********************************/ + /* Set the hardware output level */ - /*********************************/ ui_Command = ui_Command | (data[8] << 2); outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); if (data[9] == ADDIDATA_ENABLE) { - /************************/ + /* Set the reload value */ - /************************/ outl(data[11], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 24); - /**********************/ + /* Set the time unite */ - /**********************/ outl(data[10], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28); } ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*******************************/ + /* Disable the hardware output */ - /*******************************/ ui_Command = ui_Command & 0xFFFFF9F7UL; - /*********************************/ + /* Set the hardware output level */ - /*********************************/ ui_Command = ui_Command | (data[12] << 3); outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*************************************/ - /** Enable the watchdog interrupt **/ - /*************************************/ + + /* Enable the watchdog interrupt */ ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /*******************************/ + /* Set the interrupt selection */ - /*******************************/ ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16); ui_Command = (ui_Command & 0xFFFFF9FDUL) | (data[13] << 1); @@ -348,19 +329,17 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, if (data[0] == 1) { ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /**********************/ + /* Start the hardware */ - /**********************/ ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - } /* if (data[0]==1) */ + } if (data[0] == 2) { ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - /***************************/ + /* Set the trigger command */ - /***************************/ ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL; outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -375,7 +354,7 @@ static int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, */ outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - } /* if (data[1]==0) */ + } if (data[0] == 3) { /* stop all Watchdogs */ ui_Command = 0; @@ -463,28 +442,19 @@ static int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, i_WatchdogNbr = insn->unused[0]; - /******************/ /* Get the status */ - /******************/ - ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16); - /***********************************/ /* Get the software trigger status */ - /***********************************/ - data[0] = ((ui_Status >> 1) & 1); - /***********************************/ + /* Get the hardware trigger status */ - /***********************************/ data[1] = ((ui_Status >> 2) & 1); - /*********************************/ + /* Get the software clear status */ - /*********************************/ data[2] = ((ui_Status >> 3) & 1); - /***************************/ + /* Get the overflow status */ - /***************************/ data[3] = ((ui_Status >> 0) & 1); if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); @@ -525,9 +495,8 @@ static int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, devpriv->tsk_Current = current; outl(0x200 | 0, devpriv->iobase + 128 + 0x4); outl(0, devpriv->iobase + 128 + 0); - /********************************/ + /* Initialise the warning value */ - /********************************/ outl(0x300 | 0, devpriv->iobase + 128 + 0x4); outl((data[0] << 8), devpriv->iobase + 128 + 0); outl(0x200000UL, devpriv->iobase + 128 + 12); @@ -564,18 +533,13 @@ static int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct addi_private *devpriv = dev->private; unsigned int ui_CommandRegister = 0; - /******************/ /* Set the start */ - /******************/ ui_CommandRegister = 0x80000; - /******************************/ + /* Write the command register */ - /******************************/ outl(ui_CommandRegister, devpriv->iobase + 128 + 8); - /***************************************/ /* Read the digital value of the input */ - /***************************************/ data[0] = inl(devpriv->iobase + 128 + 28); return insn->n; } @@ -640,40 +604,34 @@ static void v_APCI035_Interrupt(int irq, void *d) i_WatchdogNbr = i_Flag; i_Flag = i_Flag + 1; } - /**************************************/ - /* Read the interrupt status register of temperature Warning */ - /**************************************/ - ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16); - /**************************************/ - /* Read the interrupt status register for Watchdog/timer */ - /**************************************/ + /* Read the interrupt status register of temperature Warning */ + ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16); + + /* Read the interrupt status register for Watchdog/timer */ ui_StatusRegister2 = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20); /* Test if warning relay interrupt */ if ((((ui_StatusRegister1) & 0x8) == 0x8)) { - /**********************************/ + /* Disable the temperature warning */ - /**********************************/ ui_ReadCommand = inl(devpriv->iobase + 128 + 12); ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL; outl(ui_ReadCommand, devpriv->iobase + 128 + 12); - /***************************/ + /* Read the channel number */ - /***************************/ ui_ChannelNumber = inl(devpriv->iobase + 128 + 60); - /**************************************/ + /* Read the digital temperature value */ - /**************************************/ ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60); send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } /* if (((ui_StatusRegister1 & 0x8) == 0x8)) */ + } else { if ((ui_StatusRegister2 & 0x1) == 0x1) send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } /* else if (((ui_StatusRegister1 & 0x8) == 0x8)) */ + } return; } From 711b888ea60a8002789ac04522cf38dfa7923fdc Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Mon, 24 Feb 2014 10:34:13 -0600 Subject: [PATCH 0465/1375] Staging: comedi: addi-data: cleanup conditional blocks in hwdrv_apci035.c There were some conditional blocks that had an unnecessary level of indentation in them. We can remove this to improve code clarity. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci035.c | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 7c405354d0f2..ebc05875aee3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -207,23 +207,22 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL; + } else if (data[0] == ADDIDATA_WATCHDOG) { + + /* Set the mode : */ + /* - Disable the hardware */ + /* - Disable the counter mode */ + /* - Disable the warning */ + /* - Disable the reset */ + /* - Disable the timer mode */ + + ui_Command = ui_Command & 0xFFF819E2UL; + } else { - if (data[0] == ADDIDATA_WATCHDOG) { - - /* Set the mode : */ - /* - Disable the hardware */ - /* - Disable the counter mode */ - /* - Disable the warning */ - /* - Disable the reset */ - /* - Disable the timer mode */ - - ui_Command = ui_Command & 0xFFF819E2UL; - - } else { - dev_err(dev->class_dev, "The parameter for Timer/watchdog selection is in error\n"); - return -EINVAL; - } + dev_err(dev->class_dev, "The parameter for Timer/watchdog selection is in error\n"); + return -EINVAL; } + outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); @@ -626,11 +625,9 @@ static void v_APCI035_Interrupt(int irq, void *d) /* Read the digital temperature value */ ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60); send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } - else { - if ((ui_StatusRegister2 & 0x1) == 0x1) - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + } else if ((ui_StatusRegister2 & 0x1) == 0x1) { + send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } return; From 29f813859663974296ad436c40253c40a64694a0 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Mon, 24 Feb 2014 10:35:09 -0600 Subject: [PATCH 0466/1375] Staging: comedi: addi-data: fix a couple of lines that are too long There are a couple of cases where a comment being on the same line as a statement is causing the line to be over 80 characters long. This is an easy fix, move these comments to the previous line. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci035.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index ebc05875aee3..6fca105fc0ef 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -565,7 +565,9 @@ static int i_APCI035_Reset(struct comedi_device *dev) for (i_Count = 1; i_Count <= 4; i_Count++) { i_WatchdogNbr = i_Count; - outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); /* stop all timers */ + + /* stop all timers */ + outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); } outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */ @@ -624,10 +626,13 @@ static void v_APCI035_Interrupt(int irq, void *d) /* Read the digital temperature value */ ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60); - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + + /* send signal to the sample */ + send_sig(SIGIO, devpriv->tsk_Current, 0); } else if ((ui_StatusRegister2 & 0x1) == 0x1) { - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ + /* send signal to the sample */ + send_sig(SIGIO, devpriv->tsk_Current, 0); } return; From e0f9dfaf0142e0b08fccdf838e5dd3e96592b836 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Feb 2014 10:02:53 -0500 Subject: [PATCH 0467/1375] staging: dgap: fix compile warnings by remove dead code The last patch series exposed some dead code causing compile warnings. This patch removes that dead code and fixes the warnings Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 145 ------------------------------------ 1 file changed, 145 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 21af5fa9545b..7cb1ad597ced 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -197,9 +197,6 @@ static void dgap_remove_ports_sysfiles(struct board_t *bd); static void dgap_create_driver_sysfiles(struct pci_driver *); static void dgap_remove_driver_sysfiles(struct pci_driver *); -static int dgap_tty_class_init(void); -static int dgap_tty_class_destroy(void); - static void dgap_create_tty_sysfs(struct un_t *un, struct device *c); static void dgap_remove_tty_sysfs(struct device *c); @@ -210,12 +207,10 @@ static int dgap_parsefile(char **in, int Remove); static struct cnode *dgap_find_config(int type, int bus, int slot); static uint dgap_config_get_number_of_ports(struct board_t *bd); static char *dgap_create_config_string(struct board_t *bd, char *string); -static char *dgap_get_config_letters(struct board_t *bd, char *string); static uint dgap_config_get_useintr(struct board_t *bd); static uint dgap_config_get_altpin(struct board_t *bd); static int dgap_ms_sleep(ulong ms); -static char *dgap_ioctl_name(int cmd); static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len); #ifdef DIGI_CONCENTRATORS_SUPPORTED @@ -390,29 +385,6 @@ static struct firmware_info fw_info[] = { {0,} }; -static char *dgap_state_text[] = { - "Board Failed", - "Configuration for board not found.\n\t\t\tRun mpi to configure board.", - "Board Found", - "Need Reset", - "Finished Reset", - "Need Config", - "Finished Config", - "Need Device Creation", - "Requested Device Creation", - "Finished Device Creation", - "Need BIOS Load", - "Requested BIOS", - "Doing BIOS Load", - "Finished BIOS Load", - "Need FEP Load", - "Requested FEP", - "Doing FEP Load", - "Finished FEP Load", - "Requested PROC creation", - "Finished PROC creation", - "Board READY", -}; static char *dgap_driver_state_text[] = { "Driver Initialized", @@ -1421,57 +1393,6 @@ static int dgap_ms_sleep(ulong ms) -/* - * dgap_ioctl_name() : Returns a text version of each ioctl value. - */ -static char *dgap_ioctl_name(int cmd) -{ - switch(cmd) { - - case TCGETA: return("TCGETA"); - case TCGETS: return("TCGETS"); - case TCSETA: return("TCSETA"); - case TCSETS: return("TCSETS"); - case TCSETAW: return("TCSETAW"); - case TCSETSW: return("TCSETSW"); - case TCSETAF: return("TCSETAF"); - case TCSETSF: return("TCSETSF"); - case TCSBRK: return("TCSBRK"); - case TCXONC: return("TCXONC"); - case TCFLSH: return("TCFLSH"); - case TIOCGSID: return("TIOCGSID"); - - case TIOCGETD: return("TIOCGETD"); - case TIOCSETD: return("TIOCSETD"); - case TIOCGWINSZ: return("TIOCGWINSZ"); - case TIOCSWINSZ: return("TIOCSWINSZ"); - - case TIOCMGET: return("TIOCMGET"); - case TIOCMSET: return("TIOCMSET"); - case TIOCMBIS: return("TIOCMBIS"); - case TIOCMBIC: return("TIOCMBIC"); - - /* from digi.h */ - case DIGI_SETA: return("DIGI_SETA"); - case DIGI_SETAW: return("DIGI_SETAW"); - case DIGI_SETAF: return("DIGI_SETAF"); - case DIGI_SETFLOW: return("DIGI_SETFLOW"); - case DIGI_SETAFLOW: return("DIGI_SETAFLOW"); - case DIGI_GETFLOW: return("DIGI_GETFLOW"); - case DIGI_GETAFLOW: return("DIGI_GETAFLOW"); - case DIGI_GETA: return("DIGI_GETA"); - case DIGI_GEDELAY: return("DIGI_GEDELAY"); - case DIGI_SEDELAY: return("DIGI_SEDELAY"); - case DIGI_GETCUSTOMBAUD: return("DIGI_GETCUSTOMBAUD"); - case DIGI_SETCUSTOMBAUD: return("DIGI_SETCUSTOMBAUD"); - case TIOCMODG: return("TIOCMODG"); - case TIOCMODS: return("TIOCMODS"); - case TIOCSDTR: return("TIOCSDTR"); - case TIOCCDTR: return("TIOCCDTR"); - - default: return("unknown"); - } -} /************************************************************************ * @@ -8559,69 +8480,3 @@ static char *dgap_create_config_string(struct board_t *bd, char *string) *ptr = 0xff; return string; } - - - -static char *dgap_get_config_letters(struct board_t *bd, char *string) -{ - int found = FALSE; - char *ptr = string; - struct cnode *cptr = NULL; - int len = 0; - int left = MAXTTYNAMELEN; - - if (!bd) { - return ""; - } - - for (cptr = bd->bd_config; cptr; cptr = cptr->next) { - - if ((cptr->type == BNODE) && - ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || - (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || - (cptr->u.board.type == PAPORT8))) { - - found = TRUE; - } - - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } - else { - ptr1 = cptr->u.ttyname; - } - if (ptr1) { - len = snprintf(ptr, left, "%s", ptr1); - left -= len; - ptr += len; - if (left <= 0) - break; - } - } - - if (cptr->type == CNODE) { - if (cptr->u.conc.id) { - len = snprintf(ptr, left, "%s", cptr->u.conc.id); - left -= len; - ptr += len; - if (left <= 0) - break; - } - } - - if (cptr->type == MNODE) { - if (cptr->u.module.id) { - len = snprintf(ptr, left, "%s", cptr->u.module.id); - left -= len; - ptr += len; - if (left <= 0) - break; - } - } - } - - return string; -} From b2addb4a112eb2fbf242558e01115b4ac2f6f13b Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Tue, 25 Feb 2014 19:53:00 +0000 Subject: [PATCH 0468/1375] iio:magnetometer:mag3110: Fix unreachable code drivers/iio/magnetometer/mag3110.c:197 mag3110_read_raw() info: ignoring unreachable code. drivers/iio/magnetometer/mag3110.c 185 case IIO_CHAN_INFO_SCALE: 186 switch (chan->type) { 187 case IIO_MAGN: 188 *val = 0; 189 *val2 = 1000; 190 return IIO_VAL_INT_PLUS_MICRO; 191 case IIO_TEMP: 192 *val = 1000; 193 return IIO_VAL_INT; 194 default: 195 return -EINVAL; 196 } 197 return IIO_VAL_INT_PLUS_MICRO; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ introduced by f9279d3a, mag3110: Scale factor missing Signed-off-by: Peter Meerwald Reported-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mag3110.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 02e4f9765889..8b77782474d7 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -194,7 +194,6 @@ static int mag3110_read_raw(struct iio_dev *indio_dev, default: return -EINVAL; } - return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_SAMP_FREQ: i = data->ctrl_reg1 >> MAG3110_CTRL_DR_SHIFT; *val = mag3110_samp_freq[i][0]; From 0cb4c151c3de6cfb649fd59142b144aeba77fc8b Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Tue, 25 Feb 2014 14:51:26 +0530 Subject: [PATCH 0469/1375] Staging: comedi: Fix unnecessary space after function pointer This patch fixes the following checkpatch.pl warning in comedidev.h WARNING: Fix unnecessary space after function pointer Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index f36bf3e02c41..d46123a97582 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -61,31 +61,31 @@ struct comedi_subdevice { unsigned int *chanlist; /* driver-owned chanlist (not used) */ - int (*insn_read) (struct comedi_device *, struct comedi_subdevice *, + int (*insn_read)(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); + int (*insn_write)(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, unsigned int *); - int (*insn_write) (struct comedi_device *, struct comedi_subdevice *, + int (*insn_bits)(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); + int (*insn_config)(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, unsigned int *); - int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*insn_config) (struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *); - int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *, - struct comedi_cmd *); - int (*poll) (struct comedi_device *, struct comedi_subdevice *); - int (*cancel) (struct comedi_device *, struct comedi_subdevice *); + int (*do_cmd)(struct comedi_device *, struct comedi_subdevice *); + int (*do_cmdtest)(struct comedi_device *, struct comedi_subdevice *, + struct comedi_cmd *); + int (*poll)(struct comedi_device *, struct comedi_subdevice *); + int (*cancel)(struct comedi_device *, struct comedi_subdevice *); /* int (*do_lock)(struct comedi_device *, struct comedi_subdevice *); */ /* int (*do_unlock)(struct comedi_device *, \ struct comedi_subdevice *); */ /* called when the buffer changes */ - int (*buf_change) (struct comedi_device *dev, - struct comedi_subdevice *s, unsigned long new_size); + int (*buf_change)(struct comedi_device *dev, + struct comedi_subdevice *s, unsigned long new_size); - void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s, - void *data, unsigned int num_bytes, - unsigned int start_chan_index); + void (*munge)(struct comedi_device *dev, struct comedi_subdevice *s, + void *data, unsigned int num_bytes, + unsigned int start_chan_index); enum dma_data_direction async_dma_dir; unsigned int state; @@ -146,8 +146,8 @@ struct comedi_async { unsigned int cb_mask; - int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int x); + int (*inttrig)(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned int x); }; struct comedi_driver { @@ -155,9 +155,9 @@ struct comedi_driver { const char *driver_name; struct module *module; - int (*attach) (struct comedi_device *, struct comedi_devconfig *); - void (*detach) (struct comedi_device *); - int (*auto_attach) (struct comedi_device *, unsigned long); + int (*attach)(struct comedi_device *, struct comedi_devconfig *); + void (*detach)(struct comedi_device *); + int (*auto_attach)(struct comedi_device *, unsigned long); /* number of elements in board_name and board_id arrays */ unsigned int num_names; @@ -202,8 +202,8 @@ struct comedi_device { struct fasync_struct *async_queue; - int (*open) (struct comedi_device *dev); - void (*close) (struct comedi_device *dev); + int (*open)(struct comedi_device *dev); + void (*close)(struct comedi_device *dev); }; static inline const void *comedi_board(const struct comedi_device *dev) From c095fad35ec72835540b3a9b1166dcd83a74ade3 Mon Sep 17 00:00:00 2001 From: Kumar Amit Mehta Date: Wed, 26 Feb 2014 01:04:45 +0200 Subject: [PATCH 0470/1375] staging: comedi: drivers: fix for a potential NULL pointer dereference Return -ENOMEM in ni_E_init if ni_gpct_device_construct returns NULL Signed-off-by: Kumar Amit Mehta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8adb535516bd..3a86d482babd 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4407,6 +4407,9 @@ static int ni_E_init(struct comedi_device *dev) &ni_gpct_read_register, counter_variant, NUM_GPCT); + if (!devpriv->counter_dev) + return -ENOMEM; + /* General purpose counters */ for (j = 0; j < NUM_GPCT; ++j) { s = &dev->subdevices[NI_GPCT_SUBDEV(j)]; From ea6ff788fefcb71e08fa0b1ec82c3430053bbbc2 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 26 Feb 2014 03:09:44 -0600 Subject: [PATCH 0471/1375] Staging: comedi: addi-data: clean-up variable use in hwdrv_apci035.c The variable ui_Command is as of right now being cleared to a value of zero between everytime that it writes to a port and then takes a new value from a port. Seems like this zeroing is unnecessary, so we can just remove these lines. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci035.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 6fca105fc0ef..9041fdf22b45 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -182,11 +182,9 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, else ui_Mode = 0; -/* ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); */ ui_Command = 0; -/* ui_Command = ui_Command & 0xFFFFF9FEUL; */ outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - ui_Command = 0; + ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Set the reload value */ @@ -224,7 +222,7 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - ui_Command = 0; + ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Disable the hardware trigger */ @@ -235,7 +233,7 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, ui_Command = ui_Command | (data[5] << 5); } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - ui_Command = 0; + ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Disable the hardware gate */ @@ -246,7 +244,7 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, ui_Command = ui_Command | (data[7] << 7); } outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - ui_Command = 0; + ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Disable the hardware output */ @@ -266,7 +264,6 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28); } - ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Disable the hardware output */ @@ -277,7 +274,6 @@ static int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Enable the watchdog interrupt */ - ui_Command = 0; ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); /* Set the interrupt selection */ From 223eaa377d42481c209df2d425032417b1762811 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Tue, 25 Feb 2014 10:13:49 +0900 Subject: [PATCH 0472/1375] staging: ced401: fix double unlock bug After spin_lock() is called, all of if-else conditions in this brace should reach the end of else and spin_unlock() must be called. So It doesn't need to call spin_unlock() without a return statement for handling an error. Also sparse says: drivers/staging/ced1401/usb1401.c:1080:28: warning: context imbalance in 'Handle1401Esc' - unexpected unlock Reviewed-by: Dan Carpenter Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ced1401/usb1401.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/ced1401/usb1401.c b/drivers/staging/ced1401/usb1401.c index f441e33660fe..c281fdabb4ed 100644 --- a/drivers/staging/ced1401/usb1401.c +++ b/drivers/staging/ced1401/usb1401.c @@ -1054,7 +1054,6 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh, /* This can never happen, really */ dev_err(&pdx->interface->dev, "ERROR: DMA setup while transfer still waiting\n"); - spin_unlock(&pdx->stagedLock); } else { if ((wTransType == TM_EXTTOHOST) || (wTransType == TM_EXTTO1401)) { From bc4d6dafa5ee86a8f925ee53575f1fec89ac6767 Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Tue, 25 Feb 2014 14:46:04 +0530 Subject: [PATCH 0473/1375] Staging: cxt1e1: Fix no spaces at the start of a line in functions.c This patch fixes the following checkpatch.pl warning in functions.c WARNING: please no spaces at the start of a line in Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/functions.c | 314 ++++++++++++++--------------- 1 file changed, 154 insertions(+), 160 deletions(-) diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index f5ce8529b4ae..1b3bf1b6d6fd 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -25,7 +25,7 @@ #include "pmcc4.h" #if defined(CONFIG_SBE_HDLC_V7) || defined(CONFIG_SBE_WAN256T3_HDLC_V7) || \ - defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) +defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) #define _v7_hdlc_ 1 #else #define _v7_hdlc_ 0 @@ -56,16 +56,16 @@ u_int32_t pci_read_32 (u_int32_t *p) { #ifdef FLOW_DEBUG - u_int32_t v; + u_int32_t v; - FLUSH_PCI_READ (); - v = le32_to_cpu (*p); - if (cxt1e1_log_level >= LOG_DEBUG) - pr_info("pci_read : %x = %x\n", (u_int32_t) p, v); - return v; + FLUSH_PCI_READ (); + v = le32_to_cpu (*p); + if (cxt1e1_log_level >= LOG_DEBUG) + pr_info("pci_read : %x = %x\n", (u_int32_t) p, v); + return v; #else - FLUSH_PCI_READ (); /* */ - return le32_to_cpu (*p); + FLUSH_PCI_READ (); /* */ + return le32_to_cpu (*p); #endif } @@ -73,18 +73,18 @@ void pci_write_32 (u_int32_t *p, u_int32_t v) { #ifdef FLOW_DEBUG - if (cxt1e1_log_level >= LOG_DEBUG) - pr_info("pci_write: %x = %x\n", (u_int32_t) p, v); + if (cxt1e1_log_level >= LOG_DEBUG) + pr_info("pci_write: %x = %x\n", (u_int32_t) p, v); #endif - *p = cpu_to_le32 (v); - FLUSH_PCI_WRITE (); /* This routine is called from routines - * which do multiple register writes - * which themselves need flushing between - * writes in order to guarantee write - * ordering. It is less code-cumbersome - * to flush here-in then to investigate - * and code the many other register - * writing routines. */ + *p = cpu_to_le32 (v); + FLUSH_PCI_WRITE (); /* This routine is called from routines + * which do multiple register writes + * which themselves need flushing between + * writes in order to guarantee write + * ordering. It is less code-cumbersome + * to flush here-in then to investigate + * and code the many other register + * writing routines. */ } #endif @@ -92,10 +92,10 @@ pci_write_32 (u_int32_t *p, u_int32_t v) void pci_flush_write (ci_t *ci) { - volatile u_int32_t v; + volatile u_int32_t v; /* issue a PCI read to flush PCI write thru bridge */ - v = *(u_int32_t *) &ci->reg->glcd; /* any address would do */ + v = *(u_int32_t *) &ci->reg->glcd; /* any address would do */ /* * return nothing, this just reads PCI bridge interface to flush @@ -107,53 +107,49 @@ pci_flush_write (ci_t *ci) static void watchdog_func (unsigned long arg) { - struct watchdog *wd = (void *) arg; + struct watchdog *wd = (void *) arg; - if (drvr_state != SBE_DRVR_AVAILABLE) - { - if (cxt1e1_log_level >= LOG_MONITOR) - pr_warning("%s: drvr not available (%x)\n", __func__, drvr_state); - return; - } - schedule_work (&wd->work); - mod_timer (&wd->h, jiffies + wd->ticks); + if (drvr_state != SBE_DRVR_AVAILABLE) { + if (cxt1e1_log_level >= LOG_MONITOR) + pr_warning("%s: drvr not available (%x)\n", __func__, drvr_state); + return; + } + schedule_work (&wd->work); + mod_timer (&wd->h, jiffies + wd->ticks); } int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *c, int usec) { - wdp->func = f; - wdp->softc = c; - wdp->ticks = (HZ) * (usec / 1000) / 1000; - INIT_WORK(&wdp->work, (void *)f); - init_timer (&wdp->h); - { - ci_t *ci = (ci_t *) c; + wdp->func = f; + wdp->softc = c; + wdp->ticks = (HZ) * (usec / 1000) / 1000; + INIT_WORK(&wdp->work, (void *)f); + init_timer (&wdp->h); + { + ci_t *ci = (ci_t *) c; - wdp->h.data = (unsigned long) &ci->wd; - } - wdp->h.function = watchdog_func; - return 0; + wdp->h.data = (unsigned long) &ci->wd; + } + wdp->h.function = watchdog_func; + return 0; } void OS_uwait (int usec, char *description) { - int tmp; + int tmp; - if (usec >= 1000) - { - mdelay (usec / 1000); - /* now delay residual */ - tmp = (usec / 1000) * 1000; /* round */ - tmp = usec - tmp; /* residual */ - if (tmp) - { /* wait on residual */ - udelay (tmp); - } - } else - { - udelay (usec); - } + if (usec >= 1000) { + mdelay (usec / 1000); + /* now delay residual */ + tmp = (usec / 1000) * 1000; /* round */ + tmp = usec - tmp; /* residual */ + if (tmp) { /* wait on residual */ + udelay (tmp); + } + } else { + udelay (usec); + } } /* dummy short delay routine called as a subroutine so that compiler @@ -164,9 +160,9 @@ void OS_uwait_dummy (void) { #ifndef USE_MAX_INT_DELAY - dummy++; + dummy++; #else - udelay (1); + udelay (1); #endif } @@ -174,83 +170,82 @@ OS_uwait_dummy (void) void OS_sem_init (void *sem, int state) { - switch (state) - { - case SEM_TAKEN: - sema_init((struct semaphore *) sem, 0); - break; - case SEM_AVAILABLE: + switch (state) { + case SEM_TAKEN: + sema_init((struct semaphore *) sem, 0); + break; + case SEM_AVAILABLE: sema_init((struct semaphore *) sem, 1); - break; - default: /* otherwise, set sem.count to state's - * value */ - sema_init (sem, state); - break; - } + break; + default: /* otherwise, set sem.count to state's + * value */ + sema_init (sem, state); + break; + } } int sd_line_is_ok (void *user) { - struct net_device *ndev = (struct net_device *) user; + struct net_device *ndev = (struct net_device *) user; - return netif_carrier_ok (ndev); + return netif_carrier_ok (ndev); } void sd_line_is_up (void *user) { - struct net_device *ndev = (struct net_device *) user; + struct net_device *ndev = (struct net_device *) user; - netif_carrier_on (ndev); - return; + netif_carrier_on (ndev); + return; } void sd_line_is_down (void *user) { - struct net_device *ndev = (struct net_device *) user; + struct net_device *ndev = (struct net_device *) user; - netif_carrier_off (ndev); - return; + netif_carrier_off (ndev); + return; } void sd_disable_xmit (void *user) { - struct net_device *dev = (struct net_device *) user; + struct net_device *dev = (struct net_device *) user; - netif_stop_queue (dev); - return; + netif_stop_queue (dev); + return; } void sd_enable_xmit (void *user) { - struct net_device *dev = (struct net_device *) user; + struct net_device *dev = (struct net_device *) user; - netif_wake_queue (dev); - return; + netif_wake_queue (dev); + return; } int sd_queue_stopped (void *user) { - struct net_device *ndev = (struct net_device *) user; + struct net_device *ndev = (struct net_device *) user; - return netif_queue_stopped (ndev); + return netif_queue_stopped (ndev); } void sd_recv_consume(void *token, size_t len, void *user) { - struct net_device *ndev = user; - struct sk_buff *skb = token; + struct net_device *ndev = user; + struct sk_buff *skb = token; - skb->dev = ndev; - skb_put (skb, len); - skb->protocol = hdlc_type_trans(skb, ndev); - netif_rx(skb); + skb->dev = ndev; + skb_put (skb, len); + skb->protocol = hdlc_type_trans(skb, ndev); + netif_rx(skb); } @@ -265,75 +260,74 @@ extern ci_t *CI; /* dummy pointer to board ZERO's data */ void VMETRO_TRIGGER (ci_t *ci, int x) { - struct s_comet_reg *comet; - volatile u_int32_t data; + struct s_comet_reg *comet; + volatile u_int32_t data; - comet = ci->port[0].cometbase; /* default to COMET # 0 */ + comet = ci->port[0].cometbase; /* default to COMET # 0 */ - switch (x) - { - default: - case 0: - data = pci_read_32 ((u_int32_t *) &comet->__res24); /* 0x90 */ - break; - case 1: - data = pci_read_32 ((u_int32_t *) &comet->__res25); /* 0x94 */ - break; - case 2: - data = pci_read_32 ((u_int32_t *) &comet->__res26); /* 0x98 */ - break; - case 3: - data = pci_read_32 ((u_int32_t *) &comet->__res27); /* 0x9C */ - break; - case 4: - data = pci_read_32 ((u_int32_t *) &comet->__res88); /* 0x220 */ - break; - case 5: - data = pci_read_32 ((u_int32_t *) &comet->__res89); /* 0x224 */ - break; - case 6: - data = pci_read_32 ((u_int32_t *) &comet->__res8A); /* 0x228 */ - break; - case 7: - data = pci_read_32 ((u_int32_t *) &comet->__res8B); /* 0x22C */ - break; - case 8: - data = pci_read_32 ((u_int32_t *) &comet->__resA0); /* 0x280 */ - break; - case 9: - data = pci_read_32 ((u_int32_t *) &comet->__resA1); /* 0x284 */ - break; - case 10: - data = pci_read_32 ((u_int32_t *) &comet->__resA2); /* 0x288 */ - break; - case 11: - data = pci_read_32 ((u_int32_t *) &comet->__resA3); /* 0x28C */ - break; - case 12: - data = pci_read_32 ((u_int32_t *) &comet->__resA4); /* 0x290 */ - break; - case 13: - data = pci_read_32 ((u_int32_t *) &comet->__resA5); /* 0x294 */ - break; - case 14: - data = pci_read_32 ((u_int32_t *) &comet->__resA6); /* 0x298 */ - break; - case 15: - data = pci_read_32 ((u_int32_t *) &comet->__resA7); /* 0x29C */ - break; - case 16: - data = pci_read_32 ((u_int32_t *) &comet->__res74); /* 0x1D0 */ - break; - case 17: - data = pci_read_32 ((u_int32_t *) &comet->__res75); /* 0x1D4 */ - break; - case 18: - data = pci_read_32 ((u_int32_t *) &comet->__res76); /* 0x1D8 */ - break; - case 19: - data = pci_read_32 ((u_int32_t *) &comet->__res77); /* 0x1DC */ - break; - } + switch (x) { + default: + case 0: + data = pci_read_32 ((u_int32_t *) &comet->__res24); /* 0x90 */ + break; + case 1: + data = pci_read_32 ((u_int32_t *) &comet->__res25); /* 0x94 */ + break; + case 2: + data = pci_read_32 ((u_int32_t *) &comet->__res26); /* 0x98 */ + break; + case 3: + data = pci_read_32 ((u_int32_t *) &comet->__res27); /* 0x9C */ + break; + case 4: + data = pci_read_32 ((u_int32_t *) &comet->__res88); /* 0x220 */ + break; + case 5: + data = pci_read_32 ((u_int32_t *) &comet->__res89); /* 0x224 */ + break; + case 6: + data = pci_read_32 ((u_int32_t *) &comet->__res8A); /* 0x228 */ + break; + case 7: + data = pci_read_32 ((u_int32_t *) &comet->__res8B); /* 0x22C */ + break; + case 8: + data = pci_read_32 ((u_int32_t *) &comet->__resA0); /* 0x280 */ + break; + case 9: + data = pci_read_32 ((u_int32_t *) &comet->__resA1); /* 0x284 */ + break; + case 10: + data = pci_read_32 ((u_int32_t *) &comet->__resA2); /* 0x288 */ + break; + case 11: + data = pci_read_32 ((u_int32_t *) &comet->__resA3); /* 0x28C */ + break; + case 12: + data = pci_read_32 ((u_int32_t *) &comet->__resA4); /* 0x290 */ + break; + case 13: + data = pci_read_32 ((u_int32_t *) &comet->__resA5); /* 0x294 */ + break; + case 14: + data = pci_read_32 ((u_int32_t *) &comet->__resA6); /* 0x298 */ + break; + case 15: + data = pci_read_32 ((u_int32_t *) &comet->__resA7); /* 0x29C */ + break; + case 16: + data = pci_read_32 ((u_int32_t *) &comet->__res74); /* 0x1D0 */ + break; + case 17: + data = pci_read_32 ((u_int32_t *) &comet->__res75); /* 0x1D4 */ + break; + case 18: + data = pci_read_32 ((u_int32_t *) &comet->__res76); /* 0x1D8 */ + break; + case 19: + data = pci_read_32 ((u_int32_t *) &comet->__res77); /* 0x1DC */ + break; + } } From 08e624a0923eb3aa67a733b975b02a2aacfa99eb Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Tue, 25 Feb 2014 16:12:44 +0530 Subject: [PATCH 0474/1375] Staging: cxt1e1: Fix space prohibited between function name and open parenthesis '(' This patch fixes the following checkpatch.pl warning in functions.c WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/functions.c | 114 ++++++++++++++--------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index 1b3bf1b6d6fd..f76003d46d37 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -33,9 +33,9 @@ defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE #if _v7_hdlc_ #define V7(x) (x ## _v7) -extern int hdlc_netif_rx_v7 (hdlc_device *, struct sk_buff *); -extern int register_hdlc_device_v7 (hdlc_device *); -extern int unregister_hdlc_device_v7 (hdlc_device *); +extern int hdlc_netif_rx_v7(hdlc_device *, struct sk_buff *); +extern int register_hdlc_device_v7(hdlc_device *); +extern int unregister_hdlc_device_v7(hdlc_device *); #else #define V7(x) x @@ -53,31 +53,31 @@ extern int drvr_state; #if 1 u_int32_t -pci_read_32 (u_int32_t *p) +pci_read_32(u_int32_t *p) { #ifdef FLOW_DEBUG u_int32_t v; - FLUSH_PCI_READ (); - v = le32_to_cpu (*p); + FLUSH_PCI_READ(); + v = le32_to_cpu(*p); if (cxt1e1_log_level >= LOG_DEBUG) pr_info("pci_read : %x = %x\n", (u_int32_t) p, v); return v; #else - FLUSH_PCI_READ (); /* */ - return le32_to_cpu (*p); + FLUSH_PCI_READ(); /* */ + return le32_to_cpu(*p); #endif } void -pci_write_32 (u_int32_t *p, u_int32_t v) +pci_write_32(u_int32_t *p, u_int32_t v) { #ifdef FLOW_DEBUG if (cxt1e1_log_level >= LOG_DEBUG) pr_info("pci_write: %x = %x\n", (u_int32_t) p, v); #endif *p = cpu_to_le32 (v); - FLUSH_PCI_WRITE (); /* This routine is called from routines + FLUSH_PCI_WRITE(); /* This routine is called from routines * which do multiple register writes * which themselves need flushing between * writes in order to guarantee write @@ -90,7 +90,7 @@ pci_write_32 (u_int32_t *p, u_int32_t v) void -pci_flush_write (ci_t *ci) +pci_flush_write(ci_t *ci) { volatile u_int32_t v; @@ -105,7 +105,7 @@ pci_flush_write (ci_t *ci) static void -watchdog_func (unsigned long arg) +watchdog_func(unsigned long arg) { struct watchdog *wd = (void *) arg; @@ -114,8 +114,8 @@ watchdog_func (unsigned long arg) pr_warning("%s: drvr not available (%x)\n", __func__, drvr_state); return; } - schedule_work (&wd->work); - mod_timer (&wd->h, jiffies + wd->ticks); + schedule_work(&wd->work); + mod_timer(&wd->h, jiffies + wd->ticks); } int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *c, int usec) @@ -124,7 +124,7 @@ int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *c, int usec wdp->softc = c; wdp->ticks = (HZ) * (usec / 1000) / 1000; INIT_WORK(&wdp->work, (void *)f); - init_timer (&wdp->h); + init_timer(&wdp->h); { ci_t *ci = (ci_t *) c; @@ -135,20 +135,20 @@ int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *c, int usec } void -OS_uwait (int usec, char *description) +OS_uwait(int usec, char *description) { int tmp; if (usec >= 1000) { - mdelay (usec / 1000); + mdelay(usec / 1000); /* now delay residual */ tmp = (usec / 1000) * 1000; /* round */ tmp = usec - tmp; /* residual */ if (tmp) { /* wait on residual */ - udelay (tmp); + udelay(tmp); } } else { - udelay (usec); + udelay(usec); } } @@ -157,18 +157,18 @@ OS_uwait (int usec, char *description) */ void -OS_uwait_dummy (void) +OS_uwait_dummy(void) { #ifndef USE_MAX_INT_DELAY dummy++; #else - udelay (1); + udelay(1); #endif } void -OS_sem_init (void *sem, int state) +OS_sem_init(void *sem, int state) { switch (state) { case SEM_TAKEN: @@ -179,62 +179,62 @@ OS_sem_init (void *sem, int state) break; default: /* otherwise, set sem.count to state's * value */ - sema_init (sem, state); + sema_init(sem, state); break; } } int -sd_line_is_ok (void *user) +sd_line_is_ok(void *user) { struct net_device *ndev = (struct net_device *) user; - return netif_carrier_ok (ndev); + return netif_carrier_ok(ndev); } void -sd_line_is_up (void *user) +sd_line_is_up(void *user) { struct net_device *ndev = (struct net_device *) user; - netif_carrier_on (ndev); + netif_carrier_on(ndev); return; } void -sd_line_is_down (void *user) +sd_line_is_down(void *user) { struct net_device *ndev = (struct net_device *) user; - netif_carrier_off (ndev); + netif_carrier_off(ndev); return; } void -sd_disable_xmit (void *user) +sd_disable_xmit(void *user) { struct net_device *dev = (struct net_device *) user; - netif_stop_queue (dev); + netif_stop_queue(dev); return; } void -sd_enable_xmit (void *user) +sd_enable_xmit(void *user) { struct net_device *dev = (struct net_device *) user; - netif_wake_queue (dev); + netif_wake_queue(dev); return; } int -sd_queue_stopped (void *user) +sd_queue_stopped(void *user) { struct net_device *ndev = (struct net_device *) user; - return netif_queue_stopped (ndev); + return netif_queue_stopped(ndev); } void sd_recv_consume(void *token, size_t len, void *user) @@ -243,7 +243,7 @@ void sd_recv_consume(void *token, size_t len, void *user) struct sk_buff *skb = token; skb->dev = ndev; - skb_put (skb, len); + skb_put(skb, len); skb->protocol = hdlc_type_trans(skb, ndev); netif_rx(skb); } @@ -258,7 +258,7 @@ void sd_recv_consume(void *token, size_t len, void *user) extern ci_t *CI; /* dummy pointer to board ZERO's data */ void -VMETRO_TRIGGER (ci_t *ci, int x) +VMETRO_TRIGGER(ci_t *ci, int x) { struct s_comet_reg *comet; volatile u_int32_t data; @@ -268,64 +268,64 @@ VMETRO_TRIGGER (ci_t *ci, int x) switch (x) { default: case 0: - data = pci_read_32 ((u_int32_t *) &comet->__res24); /* 0x90 */ + data = pci_read_32((u_int32_t *) &comet->__res24); /* 0x90 */ break; case 1: - data = pci_read_32 ((u_int32_t *) &comet->__res25); /* 0x94 */ + data = pci_read_32((u_int32_t *) &comet->__res25); /* 0x94 */ break; case 2: - data = pci_read_32 ((u_int32_t *) &comet->__res26); /* 0x98 */ + data = pci_read_32((u_int32_t *) &comet->__res26); /* 0x98 */ break; case 3: - data = pci_read_32 ((u_int32_t *) &comet->__res27); /* 0x9C */ + data = pci_read_32((u_int32_t *) &comet->__res27); /* 0x9C */ break; case 4: - data = pci_read_32 ((u_int32_t *) &comet->__res88); /* 0x220 */ + data = pci_read_32((u_int32_t *) &comet->__res88); /* 0x220 */ break; case 5: - data = pci_read_32 ((u_int32_t *) &comet->__res89); /* 0x224 */ + data = pci_read_32((u_int32_t *) &comet->__res89); /* 0x224 */ break; case 6: - data = pci_read_32 ((u_int32_t *) &comet->__res8A); /* 0x228 */ + data = pci_read_32((u_int32_t *) &comet->__res8A); /* 0x228 */ break; case 7: - data = pci_read_32 ((u_int32_t *) &comet->__res8B); /* 0x22C */ + data = pci_read_32((u_int32_t *) &comet->__res8B); /* 0x22C */ break; case 8: - data = pci_read_32 ((u_int32_t *) &comet->__resA0); /* 0x280 */ + data = pci_read_32((u_int32_t *) &comet->__resA0); /* 0x280 */ break; case 9: - data = pci_read_32 ((u_int32_t *) &comet->__resA1); /* 0x284 */ + data = pci_read_32((u_int32_t *) &comet->__resA1); /* 0x284 */ break; case 10: - data = pci_read_32 ((u_int32_t *) &comet->__resA2); /* 0x288 */ + data = pci_read_32((u_int32_t *) &comet->__resA2); /* 0x288 */ break; case 11: - data = pci_read_32 ((u_int32_t *) &comet->__resA3); /* 0x28C */ + data = pci_read_32((u_int32_t *) &comet->__resA3); /* 0x28C */ break; case 12: - data = pci_read_32 ((u_int32_t *) &comet->__resA4); /* 0x290 */ + data = pci_read_32((u_int32_t *) &comet->__resA4); /* 0x290 */ break; case 13: - data = pci_read_32 ((u_int32_t *) &comet->__resA5); /* 0x294 */ + data = pci_read_32((u_int32_t *) &comet->__resA5); /* 0x294 */ break; case 14: - data = pci_read_32 ((u_int32_t *) &comet->__resA6); /* 0x298 */ + data = pci_read_32((u_int32_t *) &comet->__resA6); /* 0x298 */ break; case 15: - data = pci_read_32 ((u_int32_t *) &comet->__resA7); /* 0x29C */ + data = pci_read_32((u_int32_t *) &comet->__resA7); /* 0x29C */ break; case 16: - data = pci_read_32 ((u_int32_t *) &comet->__res74); /* 0x1D0 */ + data = pci_read_32((u_int32_t *) &comet->__res74); /* 0x1D0 */ break; case 17: - data = pci_read_32 ((u_int32_t *) &comet->__res75); /* 0x1D4 */ + data = pci_read_32((u_int32_t *) &comet->__res75); /* 0x1D4 */ break; case 18: - data = pci_read_32 ((u_int32_t *) &comet->__res76); /* 0x1D8 */ + data = pci_read_32((u_int32_t *) &comet->__res76); /* 0x1D8 */ break; case 19: - data = pci_read_32 ((u_int32_t *) &comet->__res77); /* 0x1DC */ + data = pci_read_32((u_int32_t *) &comet->__res77); /* 0x1DC */ break; } } From f5bde4476b4bdfca369c26a5ef3649567fffd54c Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Tue, 25 Feb 2014 16:44:26 +0530 Subject: [PATCH 0475/1375] Staging: cxt1e1: Fix line length over 80 characters in functions.c This patch fixes the following checkpatch.pl warning in functions.c WARNING: Line length over 80 characters Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/functions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index f76003d46d37..40dbe2c623c4 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -25,7 +25,8 @@ #include "pmcc4.h" #if defined(CONFIG_SBE_HDLC_V7) || defined(CONFIG_SBE_WAN256T3_HDLC_V7) || \ -defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) +defined(CONFIG_SBE_HDLC_V7_MODULE) || \ +defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) #define _v7_hdlc_ 1 #else #define _v7_hdlc_ 0 @@ -111,14 +112,16 @@ watchdog_func(unsigned long arg) if (drvr_state != SBE_DRVR_AVAILABLE) { if (cxt1e1_log_level >= LOG_MONITOR) - pr_warning("%s: drvr not available (%x)\n", __func__, drvr_state); + pr_warning("%s: drvr not available (%x)\n", + __func__, drvr_state); return; } schedule_work(&wd->work); mod_timer(&wd->h, jiffies + wd->ticks); } -int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *c, int usec) +int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), + void *c, int usec) { wdp->func = f; wdp->softc = c; From d0bdff0db809696ebc7b58234f3ff4166844c2cd Mon Sep 17 00:00:00 2001 From: John Stultz Date: Wed, 26 Feb 2014 14:29:07 -0800 Subject: [PATCH 0476/1375] staging: Fix build issues with new binder API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new 64bit binder API causes build issues on 32bit ARM due to the lack of 64bit __get_user_asm_* implementation. Until that implementation is done, remove the choice for 32bit ARM, automatically enabling the old 32bit binder protocol. This can be reverted once a 64bit __get_user_asm_* implementation is merged. Cc: Colin Cross Cc: Arve Hjønnevåg Cc: Serban Constantinescu Cc: Android Kernel Team Reported-by: Arnd Bergmann Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 1c779efc21aa..ab28d2b5e308 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -21,7 +21,7 @@ config ANDROID_BINDER_IPC between said processes. config ANDROID_BINDER_IPC_32BIT - bool "Use old (Android 4.4 and earlier) 32-bit binder API" + bool depends on !64BIT && ANDROID_BINDER_IPC default y ---help--- From 899e5f9beb04bceb1a5cbcf696a956913d17859a Mon Sep 17 00:00:00 2001 From: Ana Rey Date: Tue, 25 Feb 2014 14:36:33 +0100 Subject: [PATCH 0477/1375] staging: rtl8187se: Deleted rtl8180_len2duration functions in r8180_core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the next warning messages by sparse tools: drivers/staging/rtl8187se/r8180_core.c:1621:5: warning: symbol 'rtl8180_len2duration' was not declared. Should it be static? drivers/staging/rtl8187se/r8180_core.c:1621:12: warning: ‘rtl8180_len2duration’ defined but not used [-Wunused-function] static u16 rtl8180_len2duration(u32 len, short rate, short *ext) ^ And the next search: $ grep -ir rtl8180_len2duration ./* ./r8180_core.c:u16 rtl8180_len2duration(u32 len, short rate, short *ext) Binary file ./r8187se.ko matches Binary file ./r8187se.o matches I decided to delete rtl8180_len2duration function. Signed-off-by: Ana Rey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/r8180_core.c | 49 -------------------------- 1 file changed, 49 deletions(-) diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 6cafee22bec4..42c1ee324d2f 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -1613,55 +1613,6 @@ static int rtl8180_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; } -/* longpre 144+48 shortpre 72+24 */ -u16 rtl8180_len2duration(u32 len, short rate, short *ext) -{ - u16 duration; - u16 drift; - *ext = 0; - - switch (rate) { - case 0: /* 1mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0x2; - drift = ((len+4)<<4) % 0x2; - if (drift == 0) - break; - duration++; - break; - case 1: /* 2mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0x4; - drift = ((len+4)<<4) % 0x4; - if (drift == 0) - break; - duration++; - break; - case 2: /* 5.5mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0xb; - drift = ((len+4)<<4) % 0xb; - if (drift == 0) - break; - duration++; - break; - default: - case 3: /* 11mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0x16; - drift = ((len+4)<<4) % 0x16; - if (drift == 0) - break; - duration++; - if (drift > 6) - break; - *ext = 1; - break; - } - - return duration; -} - static void rtl8180_prepare_beacon(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); From 56f1411415355ff8df7613a02c919a8877f9c092 Mon Sep 17 00:00:00 2001 From: Ana Rey Date: Tue, 25 Feb 2014 14:37:01 +0100 Subject: [PATCH 0478/1375] staging: rtl8187se: Convert CHANNEL_LIST typedef into a struct. The Documentation/CodingStyle doesn't recommend the use of typedef, convert this to structure. While at it, I have also renamed the variable names that were used in this typedef not to use Hungarian notation. Signed-off-by: Ana Rey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/ieee80211/ieee80211.h | 8 ++++---- drivers/staging/rtl8187se/r8180_core.c | 10 +++++----- drivers/staging/rtl8187se/r8180_wx.c | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h index 09ffd9bc8991..4978b2bba186 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h @@ -709,10 +709,10 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define MAX_IE_LEN 0xFF //+YJ,080625 -typedef struct _CHANNEL_LIST{ - u8 Channel[MAX_CHANNEL_NUMBER + 1]; - u8 Len; -}CHANNEL_LIST, *PCHANNEL_LIST; +struct rtl8187se_channel_list { + u8 channel[MAX_CHANNEL_NUMBER + 1]; + u8 len; +}; //by amy for ps #define IEEE80211_WATCH_DOG_TIME 2000 diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 42c1ee324d2f..ebdcdea0e826 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -2176,7 +2176,7 @@ static void watch_dog_adaptive(unsigned long data) add_timer(&priv->watch_dog_timer); } -static CHANNEL_LIST ChannelPlan[] = { +static struct rtl8187se_channel_list channel_plan_list[] = { {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, /* FCC */ {{1,2,3,4,5,6,7,8,9,10,11},11}, /* IC */ {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, /* ETSI */ @@ -2212,13 +2212,13 @@ static void rtl8180_set_channel_map(u8 channel_plan, { Dot11d_Init(ieee); ieee->bGlobalDomain = false; - if (ChannelPlan[channel_plan].Len != 0) { + if (channel_plan_list[channel_plan].len != 0) { /* Clear old channel map */ memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); /* Set new channel map */ - for (i = 0; i < ChannelPlan[channel_plan].Len; i++) { - if (ChannelPlan[channel_plan].Channel[i] <= 14) - GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; + for (i = 0; i < channel_plan_list[channel_plan].len; i++) { + if (channel_plan_list[channel_plan].channel[i] <= 14) + GET_DOT11D_INFO(ieee)->channel_map[channel_plan_list[channel_plan].channel[i]] = 1; } } break; diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index 9b676e027cad..498da41c408b 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -29,7 +29,7 @@ static u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000, #define RATE_COUNT ARRAY_SIZE(rtl8180_rates) -static CHANNEL_LIST DefaultChannelPlan[] = { +static struct rtl8187se_channel_list default_channel_plan[] = { {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19}, /* FCC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /* IC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /* ETSI */ @@ -1030,15 +1030,15 @@ static int r8180_wx_set_channelplan(struct net_device *dev, /* unsigned long flags; */ down(&priv->wx_sem); - if (DefaultChannelPlan[*val].Len != 0) { + if (default_channel_plan[*val].len != 0) { priv->channel_plan = *val; /* Clear old channel map 8 */ for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) GET_DOT11D_INFO(priv->ieee80211)->channel_map[i] = 0; /* Set new channel map */ - for (i = 1; i <= DefaultChannelPlan[*val].Len; i++) - GET_DOT11D_INFO(priv->ieee80211)->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1; + for (i = 1; i <= default_channel_plan[*val].len; i++) + GET_DOT11D_INFO(priv->ieee80211)->channel_map[default_channel_plan[*val].channel[i-1]] = 1; } up(&priv->wx_sem); From ffb8cc92a7c7e0a60943d116bcd13dc306526e35 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Tue, 25 Feb 2014 18:07:10 +0100 Subject: [PATCH 0479/1375] Staging: rtl8192e: Replace min macro with min_t Instead of an explicit cast the min_t macro should be used. Signed-off-by: Silvan Jegen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 6202358c2984..498995d833e7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -609,7 +609,7 @@ 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((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); From 7fba0100f232ed3fe057f688b3dcdf48b590b54e Mon Sep 17 00:00:00 2001 From: Ana Rey Date: Wed, 26 Feb 2014 10:06:00 +0100 Subject: [PATCH 0480/1375] staging: rtl8187se: Clean-up comment line style in r8180_core.c This patch clean-up comment-line style in r8180_core.c as the CodingStyle recommends. Signed-off-by: Ana Rey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/r8180_core.c | 135 +++++++++++++------------ 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index ebdcdea0e826..dec0dfc88369 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -1,31 +1,31 @@ /* - This is part of rtl818x pci OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2004-2005 - Released under the terms of GPL (General Public License) - - Parts of this driver are based on the GPL part of the official - Realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - Parts of BB/RF code are derived from David Young rtl8180 netbsd driver. - - RSSI calc function from 'The Deuce' - - Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the - Ndiswrapper's project Authors. - - A big big thanks goes also to Realtek corp. for their help in my attempt to - add RTL8185 and RTL8225 support, and to David Young also. - - Power management interface routines. - Written by Mariusz Matuszek. -*/ + * This is part of rtl818x pci OpenSource driver - v 0.1 + * Copyright (C) Andrea Merello 2004-2005 + * Released under the terms of GPL (General Public License) + * + * Parts of this driver are based on the GPL part of the official + * Realtek driver. + * + * Parts of this driver are based on the rtl8180 driver skeleton + * from Patric Schenke & Andres Salomon. + * + * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. + * + * Parts of BB/RF code are derived from David Young rtl8180 netbsd driver. + * + * RSSI calc function from 'The Deuce' + * + * Some ideas borrowed from the 8139too.c driver included in linux kernel. + * + * We (I?) want to thanks the Authors of those projecs and also the + * Ndiswrapper's project Authors. + * + * A big big thanks goes also to Realtek corp. for their help in my attempt to + * add RTL8185 and RTL8225 support, and to David Young also. + * + * Power management interface routines. + * Written by Mariusz Matuszek. + */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -347,9 +347,9 @@ static void rtl8180_proc_init_one(struct net_device *dev) } /* - FIXME: check if we can use some standard already-existent - data type+functions in kernel -*/ + * FIXME: check if we can use some standard already-existent + * data type+functions in kernel. + */ static short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma, struct buffer **bufferhead) @@ -1206,8 +1206,9 @@ static void rtl8180_rx(struct net_device *dev) rx_desc_size = 8; if ((*(priv->rxringtail)) & (1<<31)) { - /* we have got an RX int, but the descriptor - * we are pointing is empty */ + /* we have got an RX int, but the descriptor. we are pointing + * is empty. + */ priv->stats.rxnodata++; priv->ieee80211->stats.rx_errors++; @@ -1254,10 +1255,9 @@ static void rtl8180_rx(struct net_device *dev) if (last) { lastlen = ((*priv->rxringtail) & 0xfff); - /* if the last descriptor (that should - * tell us the total packet len) tell - * us something less than the descriptors - * len we had until now, then there is some + /* if the last descriptor (that should tell us the total + * packet len) tell us something less than the + * descriptors len we had until now, then there is some * problem.. * workaround to prevent kernel panic */ @@ -1293,11 +1293,11 @@ static void rtl8180_rx(struct net_device *dev) priv->rx_prevlen += len; if (priv->rx_prevlen > MAX_FRAG_THRESHOLD + 100) { - /* HW is probably passing several buggy frames - * without FD or LD flag set. - * Throw this garbage away to prevent skb - * memory exhausting - */ + /* HW is probably passing several buggy frames without + * FD or LD flag set. + * Throw this garbage away to prevent skb memory + * exhausting + */ if (!priv->rx_skb_complete) dev_kfree_skb_any(priv->rx_skb); priv->rx_skb_complete = 1; @@ -1361,7 +1361,9 @@ static void rtl8180_rx(struct net_device *dev) quality = 127 - quality; priv->SignalQuality = quality; - stats.signal = (u8)quality; /*priv->wstats.qual.level = priv->SignalStrength; */ + stats.signal = (u8)quality; /* priv->wstats.qual.level = priv-> + * SignalStrength; + */ stats.signalstrength = RXAGC; if (stats.signalstrength > 100) stats.signalstrength = 100; @@ -1402,14 +1404,17 @@ static void rtl8180_rx(struct net_device *dev) priv->LastSignalStrengthInPercent = SignalStrengthIndex; priv->Stats_SignalStrength = TranslateToDbm8185((u8)SignalStrengthIndex); - /* - * We need more correct power of received packets and the "SignalStrength" of RxStats is beautified, - * so we record the correct power here. - */ + /* + * We need more correct power of received packets and + * the "SignalStrength" of RxStats is beautified, + * so we record the correct power here. + */ priv->Stats_SignalQuality = (long)(priv->Stats_SignalQuality * 5 + (long)priv->SignalQuality + 5) / 6; priv->Stats_RecvSignalPower = (long)(priv->Stats_RecvSignalPower * 5 + priv->RecvSignalPower - 1) / 6; - /* Figure out which antenna that received the last packet. */ + /* Figure out which antenna that received the last + * packet. + */ priv->LastRxPktAntenna = Antenna ? 1 : 0; /* 0: aux, 1: main. */ SwAntennaDiversityRxOk8185(dev, priv->SignalStrength); } @@ -1417,7 +1422,8 @@ static void rtl8180_rx(struct net_device *dev) if (first) { if (!priv->rx_skb_complete) { /* seems that HW sometimes fails to receive and - doesn't provide the last descriptor */ + * doesn't provide the last descriptor. + */ dev_kfree_skb_any(priv->rx_skb); priv->stats.rxnolast++; } @@ -1428,12 +1434,12 @@ static void rtl8180_rx(struct net_device *dev) priv->rx_skb_complete = 0; priv->rx_skb->dev = dev; } else { - /* if we are here we should have already RXed - * the first frame. - * If we get here and the skb is not allocated then - * we have just throw out garbage (skb not allocated) - * and we are still rxing garbage.... - */ + /* if we are here we should have already RXed the first + * frame. + * If we get here and the skb is not allocated then + * we have just throw out garbage (skb not allocated) + * and we are still rxing garbage.... + */ if (!priv->rx_skb_complete) { tmp_skb = dev_alloc_skb(priv->rx_skb->len+len+2); @@ -1547,11 +1553,10 @@ static void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, rate = ieeerate2rtlrate(rate); /* - * This function doesn't require lock because we make - * sure it's called with the tx_lock already acquired. - * this come from the kernel's hard_xmit callback (through - * the ieee stack, or from the try_wake_queue (again through - * the ieee stack. + * This function doesn't require lock because we make sure it's called + * with the tx_lock already acquired. + * This come from the kernel's hard_xmit callback (through the ieee + * stack, or from the try_wake_queue (again through the ieee stack. */ priority = AC2Q(skb->priority); spin_lock_irqsave(&priv->tx_lock, flags); @@ -1632,9 +1637,9 @@ static void rtl8180_prepare_beacon(struct net_device *dev) } /* - * This function do the real dirty work: it enqueues a TX command - * descriptor in the ring buffer, copyes the frame in a TX buffer - * and kicks the NIC to ensure it does the DMA transfer. + * This function do the real dirty work: it enqueues a TX command descriptor in + * the ring buffer, copyes the frame in a TX buffer and kicks the NIC to ensure + * it does the DMA transfer. */ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, short morefrag, short descfrag, int rate) @@ -2763,9 +2768,9 @@ void rtl8180_start_tx_beacon(struct net_device *dev) word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; word |= 1000; /* priv->ieee80211->current_network.beacon_interval * - ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); - // FIXME: check if correct ^^ worked with 0x3e8; - */ + * ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); + * FIXME: check if correct ^^ worked with 0x3e8; + */ write_nic_word(dev, BintrItv, word); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); From 68d386bf3f8158196429d7dc8c6dd90b15f85a99 Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Tue, 25 Feb 2014 19:40:49 +0530 Subject: [PATCH 0481/1375] Staging: panel: Fix space prohibited between function name and open paranthesis This patch fixes the following checkpatch.pl issues in panel.c: WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index ec4b1fd14021..83ce6f8c9f10 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -171,8 +171,8 @@ struct logical_input { union { struct { /* valid when type == INPUT_TYPE_STD */ - void (*press_fct) (int); - void (*release_fct) (int); + void (*press_fct)(int); + void (*release_fct)(int); int press_data; int release_data; } std; @@ -417,9 +417,9 @@ static char lcd_must_clear; static char lcd_left_shift; static char init_in_progress; -static void (*lcd_write_cmd) (int); -static void (*lcd_write_data) (int); -static void (*lcd_clear_fast) (void); +static void (*lcd_write_cmd)(int); +static void (*lcd_write_data)(int); +static void (*lcd_clear_fast)(void); static DEFINE_SPINLOCK(pprt_lock); static struct timer_list scan_timer; @@ -2017,9 +2017,9 @@ static struct logical_input *panel_bind_key(const char *name, const char *press, * be bound. */ static struct logical_input *panel_bind_callback(char *name, - void (*press_fct) (int), + void (*press_fct)(int), int press_data, - void (*release_fct) (int), + void (*release_fct)(int), int release_data) { struct logical_input *callback; From fe5d2e012a78b2fbfe255a8f360881fca329031f Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Tue, 25 Feb 2014 19:42:46 +0530 Subject: [PATCH 0482/1375] Staging: panel: Fix quoted string split across line in panel.c This patch fixes the following checkpatch.pl warning in panel.c: WARNING: quoted string split across lines Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 83ce6f8c9f10..08f9a4896116 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -457,14 +457,12 @@ MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); static int lcd_type = -1; module_param(lcd_type, int, 0000); MODULE_PARM_DESC(lcd_type, - "LCD type: 0=none, 1=old //, 2=serial ks0074, " - "3=hantronix //, 4=nexcom //, 5=compiled-in"); + "LCD type: 0=none, 1=old //, 2=serial ks0074, 3=hantronix //, 4=nexcom //, 5=compiled-in"); static int lcd_proto = -1; module_param(lcd_proto, int, 0000); MODULE_PARM_DESC(lcd_proto, - "LCD communication: 0=parallel (//), 1=serial," - "2=TI LCD Interface"); + "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface"); static int lcd_charset = -1; module_param(lcd_charset, int, 0000); @@ -473,8 +471,7 @@ MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); static int keypad_type = -1; module_param(keypad_type, int, 0000); MODULE_PARM_DESC(keypad_type, - "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, " - "3=nexcom 4 keys"); + "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 keys"); static int profile = DEFAULT_PROFILE; module_param(profile, int, 0000); @@ -494,38 +491,32 @@ MODULE_PARM_DESC(profile, static int lcd_e_pin = PIN_NOT_SET; module_param(lcd_e_pin, int, 0000); MODULE_PARM_DESC(lcd_e_pin, - "# of the // port pin connected to LCD 'E' signal, " - "with polarity (-17..17)"); + "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)"); static int lcd_rs_pin = PIN_NOT_SET; module_param(lcd_rs_pin, int, 0000); MODULE_PARM_DESC(lcd_rs_pin, - "# of the // port pin connected to LCD 'RS' signal, " - "with polarity (-17..17)"); + "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)"); static int lcd_rw_pin = PIN_NOT_SET; module_param(lcd_rw_pin, int, 0000); MODULE_PARM_DESC(lcd_rw_pin, - "# of the // port pin connected to LCD 'RW' signal, " - "with polarity (-17..17)"); + "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)"); static int lcd_bl_pin = PIN_NOT_SET; module_param(lcd_bl_pin, int, 0000); MODULE_PARM_DESC(lcd_bl_pin, - "# of the // port pin connected to LCD backlight, " - "with polarity (-17..17)"); + "# of the // port pin connected to LCD backlight, with polarity (-17..17)"); static int lcd_da_pin = PIN_NOT_SET; module_param(lcd_da_pin, int, 0000); MODULE_PARM_DESC(lcd_da_pin, - "# of the // port pin connected to serial LCD 'SDA' " - "signal, with polarity (-17..17)"); + "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)"); static int lcd_cl_pin = PIN_NOT_SET; module_param(lcd_cl_pin, int, 0000); MODULE_PARM_DESC(lcd_cl_pin, - "# of the // port pin connected to serial LCD 'SCL' " - "signal, with polarity (-17..17)"); + "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)"); static const unsigned char *lcd_char_conv; From 7f4392aa87448bca69aa46b185744b15106e5a13 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 25 Feb 2014 12:43:41 +0100 Subject: [PATCH 0483/1375] imx-drm: Move IPU_PIX_FMT_GBR24 definition into imx-ipu-v3.h The IPU display controller supports a non-standard green-red-blue ordered format that is used on the connection between IPU display interface 1 and the TV encoder on i.MX53. In preparation for the move of IPU core code out of staging, place the IPU_PIX_FMT_GBR24 definition in imx-ipu-v3.h, so that both the IPU display interface driver and the TVE encoder driver can access it. Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-drm.h | 4 ---- drivers/staging/imx-drm/imx-tve.c | 1 + drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index aa2102866689..035ab6258ad0 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -1,10 +1,6 @@ #ifndef _IMX_DRM_H_ #define _IMX_DRM_H_ -#include - -#define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3') - struct device_node; struct drm_crtc; struct drm_connector; diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 702c0c3204ed..50b25f1a85d5 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -31,6 +31,7 @@ #include #include +#include "ipu-v3/imx-ipu-v3.h" #include "imx-drm.h" #define TVE_COM_CONF_REG 0x00 diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h index 4826b5c0249d..c4d14ead5837 100644 --- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h +++ b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h @@ -25,6 +25,8 @@ enum ipuv3_type { IPUV3H, }; +#define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3') + /* * Bitfield of Display Interface signal polarities. */ From 1f15b69b597087937f370179661cc468f46ce545 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 25 Feb 2014 12:43:42 +0100 Subject: [PATCH 0484/1375] imx-drm: ipu-dc: Use usleep_range instead of msleep Since msleep(2) can sleep up to 20ms anyway, make this explicit by using usleep_range(2000, 20000). Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-dc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index d0e3bc3c53e7..d5de8bb5c803 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c @@ -262,7 +262,7 @@ void ipu_dc_disable_channel(struct ipu_dc *dc) /* Wait for DC triple buffer to empty */ while ((readl(priv->dc_reg + DC_STAT) & val) != val) { - msleep(2); + usleep_range(2000, 20000); timeout -= 2; if (timeout <= 0) break; From 628f435be4359e6ae8ecfdda9b492053be76a057 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 25 Feb 2014 11:55:04 +0100 Subject: [PATCH 0485/1375] imx-drm: parallel-display: Add drm_panel support This patch allows to optionally attach the parallel-display to a panel supported by a drm_panel driver instead of supplying the modes via device tree. Before: parallel-display { compatible = "fsl,imx-parallel-display"; ... display-timings { native-timing = <&timing1>; timing1: etm0700g0dh6 { hactive = <800>; vactive = <480>; clock-frequency = <33260000>; hsync-len = <128>; hback-porch = <88>; hfront-porch = <40>; vsync-len = <2>; vback-porch = <33>; vfront-porch = <10>; hsync-active = <0>; vsync-active = <0>; ... }; }; ... }; After: parallel-display { compatible = "fsl,imx-parallel-display"; fsl,panel = <&panel>; ... }; panel: panel { compatible = "edt,etm0700g0dh6", "simple-panel"; }; Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/Kconfig | 1 + drivers/staging/imx-drm/parallel-display.c | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig index 78319ad176cd..c6e8ba7b3e4e 100644 --- a/drivers/staging/imx-drm/Kconfig +++ b/drivers/staging/imx-drm/Kconfig @@ -20,6 +20,7 @@ config DRM_IMX_FB_HELPER config DRM_IMX_PARALLEL_DISPLAY tristate "Support for parallel displays" + select DRM_PANEL depends on DRM_IMX select VIDEOMODE_HELPERS diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index d610f0726bb2..6bce1405efd2 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include